There is a created web application that works correctly from under VS - registration and authorization of users occurs without problems. The application uses ASP.NET Identity to register users.

This is my first web application and I do not know how to publish it correctly. For a start, I'm trying to publish it on a local computer. The application itself is published without problems and works correctly. But when you try to enter the authorization or registration of a new user appears:

There was a network or instance error while connecting to SQL Server. Server not found or unavailable. Ensure that the instance name is correct and that remote connections are allowed on SQL Server. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. It is not possible to create an automatic instance. For more information about the error, see the Windows application event log.

The application is published in C:\inetpub\wwwroot\monit95 . I started to study the problem and as far as I was able to notice the user database stored in the project ...\App_Data\aspnet-WebApplication1-20150706062157.mdf did not ...\App_Data\aspnet-WebApplication1-20150706062157.mdf when published - at least I never found the aspnet-WebApplication1-20150706062157.mdf :

enter image description here

I don’t know for sure, but I think this file should also be present. I think the application is trying to access this particular file, because it is listed in Web.config :

 <connectionStrings> <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-WebApplication1-20150706062157.mdf;Initial Catalog=aspnet-WebApplication1-20150706062157;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings> 

What to do? How to publish the application? Maybe the IIS server itself needs to be configured?

    1 answer 1

    Database and should not be transferred when publishing! The fact is that the publication of the application is a multiple process, and it is impossible to overwrite the database that already exists on the site. Instead, either the database on the site must be deployed by third-party tools, or the application must deploy it itself (for example, through the Entity Framework migration mechanism).

    In any case, the IIS application should not and cannot (with rare exceptions) use LocalDB. LocalDB is a developer-only database. You need to install a full-fledged edition of SQL Server on the server (for example, SQL Server Express) and replace the connection string through the publish parameters mechanism.