Search code examples
c#asp.net-mvcweb-deploymentasp.net-authentication

Deploy user information database


I have created a simple ASP.NET MVC application with the built-in individual user authentication.
When I start local debugging (using VS2013 with iisExpress) I can register and login new users perfectly.

Then I deployed the project to Somee.com free hosting using the VS Publish option and manually deploying the App_Data folder. Here I can see pages and webAPI actions but I can't register or login users anymore, i got the error:

[Win32Exception (0x80004005): The system cannot find the file specified]

[SqlException (0x80131904): 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: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)]

System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +414
......
......

I think it's because it can't find the .mdf that contains users data or iis can't read it, but how can I resolve this?
Do I have to set up a users table on an SqlServer DB instead of using local mdf?

It's useless to post my code because I haven't change a single line of what is the visual studio template.
Thanks!


Solution

  • The template uses the Local DB feature of SQL Server, which requires a SQL Server installed on the machine (with VS you automatically have a SQL Server Express installed on your development machine).

    In my opinion you should set up a SQL Server (Express should do it for the moment) and change the connection string in your web.config to point to the new SQL Server (or leave it as it is when you deploy the database to the same machine as the website).

    If you use the Publish feature of VS you should get a hint in the wizard when reviewing the configuration that Local DB will not work if the database is on a remote machine.