Search code examples
c#asp.netiissql-server-express

ASP.NET losing connection to SQL Server Express after being published to IIS


I have an ASP.NET application that gets data from a SQL Server Express on the same computer. When I run the ASP.NET project from Visual Studio, the project can reach the database just fine. However, when published to IIS, the project loses the connection. Here is my connection string located in Web.config:

<connectionStrings>
    <add name="conString" 
         providerName="System.Data.SqlClient" 
         connectionString="Server = DESKTOP-EVAN\SERVER;Database=master;User ID=sa;Password=12345;" />
</connectionStrings>

The project can be reached on the published IIS, however no data is there and no error messages show.

I've added the application pool and NT Authority to the SQL login but still no luck connection to the database.

Does anyone have any experience with this? How can I get my published ASP.NET project to connect to my SQL Server Express?


Solution

  • Have you tried removing the spaces for the server like this:

     Server=DESKTOP-EVAN\SERVER