asp.net-mvc – 建立与SQL Server的连接时发生网络相关或特定于实例的错误

前端之家收集整理的这篇文章主要介绍了asp.net-mvc – 建立与SQL Server的连接时发生网络相关或特定于实例的错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在azurewebsites上有一个简单的mvc网站(使用VS互联网模板),与同一数据中心的sql Azure数据库通信.此时数据库只是用于内置的SimpleMembership Provider.我已经从默认的App_Data mdf文件切换到Azure sql.它工作正常,但有时一段时间后,它会给:

A network-related or instance-specific error occurred while
establishing a connection to 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. (provider: sql
Network Interfaces,error: 26 – Error Locating Server/Instance
Specified)

留言很长:

sqlExpress database file auto-creation error:

The connection string specifies a local sql Server Express instance
using a database location within the application’s App_Data directory.
The provider attempted to automatically create the application
services database because the provider determined that the database
does not exist. The following configuration requirements are necessary
to successfully check for existence of the application services
database and automatically create the application services database:

但我没有使用sql Server Express的连接字符串!

立即重新启动网站不会删除错误.

没有改变任何东西并在15分钟后重新启动网站给出:

502 – Web server received an invalid response while acting as a
gateway or proxy server.

There is a problem with the page you are looking for,and it cannot be
displayed. When the Web server (while acting as a gateway or proxy)
contacted the upstream content server,it received an invalid response
from the content server.

以前,我可以通过从VS重新发布将网站恢复到正常工作状态.但是在过去的一个小时里,我一直在努力尝试,但我无法让网站重新开始工作.

sql Server Express真的有什么问题?

我的连接字符串部分包含:

<connectionStrings>
  <add name="DefaultConnection" connectionString="Server=tcp:sabl6h4---.database.windows.net,1433;Database=MVC;User ID=test@sabl6h4---;Password=----;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;" providerName="System.Data.sqlClient" />
  <add name="Entities" connectionString="Metadata=res://*/Data.Model1.csdl|res://*/Data.Model1.ssdl|res://*/Data.Model1.msl;provider=System.Data.sqlClient;provider connection string=&quot;data source=sabl6h4---.database.windows.net;initial catalog=MVC;user id=test;password=----;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
 </connectionStrings>

为了确保,我将sabl6h4—.database.windows.net复制并粘贴到SSMS中,并使用登录测试进行连接,它打开数据库没有问题.

一天后:我创建了一个新的azurewebsite并发布了完全相同的项目和相同的web.config.它没有问题,工作正常.几分钟后,发生了完全相同的错误

再过三个小时:去吃午饭,回来,点击浏览器刷新按钮,网站再次启动.我确信有人在后端的设置中鬼混.

解决方法

添加< clear /> element作为connectionstrings元素下的第一个元素,以确保不会继承任何字符串.另外,我假设你的Azure sql DB设置了适当的防火墙设置,允许你的IP部署ASP.net代码
原文链接:https://www.f2er.com/aspnet/251725.html

猜你在找的asp.Net相关文章