加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

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

发布时间:2020-12-16 00:13:14 所属栏目:asp.Net 来源:网络整理
导读:我在azurewebsites上有一个简单的mvc网站(使用VS互联网模板),与同一数据中心的SQL Azure数据库通信.此时数据库只是用于内置的SimpleMembership Provider.我已经从默认的App_Data mdf文件切换到Azure SQL.它工作正常,但有时一段时间后,它会给: A network-rel
我在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代码?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读