Click here to Skip to main content
15,867,780 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Posted
Updated 28-Aug-17 18:10pm
v5

1 solution

 
Share this answer
 
Comments
Member 12824529 28-Aug-17 21:06pm    
Thanks. The link has numerous fixes, but nothing seems to be phasing this aggressive issue. I found another fix that said to go to IPAll in Config Manager, clear TCP Dynamic Ports, and enter 1433 in the TCP Port field. I tried that too and I'm still unable to do sign-ins on my web app. I never mentioned ... when I click on Sign-in, it says "Use another service to log in. There are no external authentication services configured. Then it provides a link for setting up external services, but I with I could get this service working. One great thing about Microsoft is they make me feel much better when my software has a bug or two on the first round. I wanted to mention ... in the past, this authentication worked for me when I was using LocalDB. But IIS wouldn't work and I read that IIS requires SQL Server Express. That's why I spent a day uninstalling SQL Server LocalDB and installing SQL Server Express.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900