如何解决ASP.NET用户登录无法访问SQL Server的问题? [英] How do I fix the issue where ASP.NET user log-in cannot access SQL server?

查看:140
本文介绍了如何解决ASP.NET用户登录无法访问SQL Server的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows 10上运行VS2015和SQL Server 2016.我正在尝试使用Forms身份验证在MVC5中运行;但即使我在跟踪微软的演练时尝试新的MVC测试应用程序,当我尝试注册新用户时出现以下错误:



--- -------------------------------------------------- ------------------------

建立与SQL Server的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。 (提供程序:SQL网络接口,错误:50 - 发生本地数据库运行时错误。无法创建自动实例。请参阅Windows应用程序事件日志以获取错误详细信息。)



描述:在执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。



异常详细信息: System.Data.SqlClient.SqlException:建立与SQL的连接时发生网络相关或特定于实例的错误服务器。服务器未找到或无法访问。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。 (提供者:SQL网络接口,错误:50 - 发生本地数据库运行时错误。无法创建自动实例。请参阅Windows

应用程序事件日志以获取错误详细信息。

- -------------------------------------------------- ---------------------------



如下所述,我是还看到SQL Server没有IP地址。我认为这是核心问题,但我该如何解决呢?我认为启用TCP / IP可以做到这一点。谢谢。



我尝试了什么:



1.我在Web.config中将身份验证模式设置为表单。



2.我在SQL Server中检查了允许远程连接到此服务器。



3.在SQL Server配置管理器(SSCM)中启用TCP / IP和命名管道协议,以及现有的共享内存。



4.执行以下查询在SQL Server中验证SQL Server没有任何IP地址,它应该有。



SELECT CONNECTIONPROPERTY('local_net_address')AS [SQL Server的IP地址]



5.我回到Configuration Manager并为TCP端口指定了49170并重新启动了SQL Server。然后我回到具有高级安全性的防火墙并删除并创建了一个新的入站规则并将其指向本地端口49170.然后我成功登录到SSMS,其中包含IP地址,后跟逗号和端口号。现在在SSMS中,它最终显示了IP地址。但是,在MVC中,尝试注册新用户时的结果没有变化。它仍然说找不到服务器而且无法访问。如果我单击登录,它会说使用其他服务登录。

I'm running VS2015 and SQL Server 2016 on Windows 10. I am trying to get Forms Authentication to work in MVC5; but even when I try a new MVC test application while following the walkthrough by Microsoft, I get the following error when I try to register a new user:

-----------------------------------------------------------------------------
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: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: 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: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows
Application event log for error details.
------------------------------------------------------------------------------

As mentioned below, I'm also seeing that SQL Server doesn't have an IP address. I think that's the core issue, but how do I fix that? I thought enabling TCP/IP would do it. Thank you.

What I have tried:

1. I set Authentication Mode to "Forms" in Web.config.

2. I verified that "Allow remote connections to this server" is checked in SQL Server.

3. Enabled TCP/IP and Named Pipes protocols, in addition to the existing Shared Memory, in SQL Server Configuration Manager (SSCM).

4. Ran the following query in SQL Server and verified that SQL Server does not have any IP address, which it is supposed to have.

SELECT CONNECTIONPROPERTY('local_net_address') AS [IP Address Of SQL Server]

5. I went back into Configuration Manager and specified 49170 for the TCP port and restarted the SQL Server. Then I went back into the Firewall w/ Advanced Security and deleted and created a new inbound rule and pointed it to local port 49170. I then successfully logged into SSMS with the IP address followed by a comma and the port number. And now in SSMS, it shows the IP address finally. However, in MVC, the result when trying to register a new user hasn't budged. It still says the server is not found and not accessible. And if I click Log In, it says to use another service to log in.

推荐答案

试试这个: c# - SQL网络接口,错误:50 - 发生本地数据库运行时错误。无法创建自动实例 - Stack Overflow [ ^ ]


这篇关于如何解决ASP.NET用户登录无法访问SQL Server的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆