[英]SQL Server Error After Web Deploy of App to Separate Web Server
I'm getting the following error once I move the app off onto its own Windows 2012 R2 IIS web server that is on Prem. 将应用程序移至Prem上其自己的Windows 2012 R2 IIS Web服务器后,出现以下错误。 The SQL 2014 DB server is in Azure.
SQL 2014数据库服务器在Azure中。 Firewall is disabled.
防火墙已禁用。
A network-related or instance-specific error occurred while establishing a connection to SQL Server.
建立与SQL Server的连接时发生与网络相关或特定于实例的错误。 The server was not found or was not accessible.
服务器未找到或无法访问。 Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
验证实例名称正确,并且已将SQL Server配置为允许远程连接。 (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
(提供者:SQL网络接口,错误:26-指定服务器/实例时出错)
Further: 进一步:
The connection string specifies a local Sql Server Express instance using a database location within the application's App_Data directory.
连接字符串使用应用程序的App_Data目录中的数据库位置指定本地Sql Server Express实例。 The provider attempted to automatically create the application services database because the provider determined that the database does not exist.
提供者尝试自动创建应用程序服务数据库,因为提供者确定该数据库不存在。
My connection strings DO NOT specify any local SQL Express DB: 我的连接字符串不指定任何本地SQL Express数据库:
<connectionStrings>
<remove name ="NewUserToolContext"/>
<remove name ="DefaultConnection"/>
<add name="NewUserToolContext" connectionString="Data Source=SQLDBSERVERNAME;Initial Catalog=NewUserTool;Integrated Security=False;User Id = USERID;password = PASSWORD" providerName="System.Data.SqlClient" />
<add name="DefaultConnection" connectionString="Data Source=SQLDBSERVERNAME;Initial Catalog=NewUserTool;Integrated Security=False;User Id = USERID;password = PASSWORD" providerName="System.Data.SqlClient" />
</connectionStrings>
My partial _Layout view has some code that checks role membership before displaying specific menu items. 我的_Layout部分视图具有一些代码,这些代码在显示特定菜单项之前检查角色成员身份。 After doing a lot of searches on this I found old posts from 2012 and one post from way back in 2013 regarding some kind of membership initializer.
经过大量搜索之后,我发现了2012年的旧帖子和2013年的一篇关于某种成员初始化程序的帖子。 The post was incredibly vague and confusing and didn't seem relevant.
该帖子令人难以置信的模糊和混乱,似乎并不相关。 It also didn't explain anything about what to do, especially not for MVC 6 Entity Framework in 2017. I tried, I couldn't find anything they were talking about.
它也没有解释该怎么做,尤其是2017年的MVC 6 Entity Framework。我尝试过,我找不到他们在说什么。 I started learning ASP.NET last year with MVC 6.
我从去年开始使用MVC 6学习ASP.NET。
Firstly, have you enable 1433 port in the firewall of your VM? 首先,您是否在VM的防火墙中启用了1433端口? If no, you could turn on this port using following steps.
如果否,则可以使用以下步骤打开此端口。
Secondly, you also need to enable 1433 port in Network Security Group which related to your VM. 其次,您还需要在Network Security Group中启用与您的VM相关的1433端口。 Steps below are for your reference.
以下步骤供您参考。
Edit 2017/6/13 编辑2017/6/13
Firstly, I suggest you write the connection string to a log file before using it on your server. 首先,我建议您在服务器上使用连接字符串之前将其写入日志文件。 You will find whether the right connection string is used to connect your server.
您会发现是否使用正确的连接字符串来连接服务器。 Maybe the connection string is override by other configurations.
也许连接字符串被其他配置覆盖。
In addition, is your web server hosted on Azure VM or local machine? 此外,您的Web服务器是否托管在Azure VM或本地计算机上?
Please also try to enable 32-bit applications in your app pool advanced setting. 也请尝试在您的应用程序池高级设置中启用32位应用程序。
Some other things you could try. 您可以尝试其他一些方法。
Please check whether you have configured Dynamic IP Security or ipSecurity in your web.config. 请检查您是否在web.config中配置了动态IP安全性或ipSecurity。 It will block any IP addresses based on your configuration.
它将根据您的配置阻止任何IP地址。
Have you tried removing all the original files at your test server when deploying your release? 在部署发行版时,您是否尝试过删除测试服务器上的所有原始文件?
After discovering finally that it was not using the correct connection strings I provided in the web.config
, but rather the LocalSqlServer
connection string in the machine.config
, I soon realized that it was using that because it was being referenced in the AspNetSqlMembershipProvider
and AspNetSqlProfileProvider
and role provider sections in the machine.config. 最终发现它使用的不是我在
web.config
提供的正确连接字符串,而是使用了machine.config
的LocalSqlServer
连接字符串后,我很快意识到它正在使用它,因为它在AspNetSqlMembershipProvider
和AspNetSqlProfileProvider
被引用和machine.config中的角色提供程序部分。 I had to find/replace everything referencing LocalSqlServer
and replace it with the connection name I wanted to use, DefaultConnection
. 我必须查找/替换所有引用
LocalSqlServer
,并将其替换为我想使用的连接名称DefaultConnection
。 I then had to run aspnet_regsql.exe
on my developer machine from the visual studio command prompt, and point it to the database to create the schema. 然后,我必须在Visual Studio命令提示符下的开发人员计算机上运行
aspnet_regsql.exe
,并将其指向数据库以创建架构。 After this my application began working. 之后,我的应用程序开始工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.