How to deploy ASP.NET MVC 4 application using localDB to local IIS on Windows 7?

37,983

Solution 1

I was also suffering from same problem, but there is a solution for it.

Go to the IIS server, and then to the application pool from which your application is running. In the advanced settings of the application pool there is a "Process Model" option, under which there is an "Identity" option. This is by default the application pool identity. Change it to Local System, and you're done.

And Remember to Put App_Data Folder their in WWW folder of IIS server

Solution 2

Try this,this will solve your problem:

Edit the applicationHost.config file found in %windir%\system32\inetsrv\config\ specifically the ApplicationPools section.

Change the IdentityType to NetworkService to use newly created database.

<add name="ASP.NET v4.0" managedRuntimeVersion="v4.0">
   <processModel identityType="NetworkService" loadUserProfile="true" setProfileEnvironment="true" />
</add>

Solution 3

Make sure that the application pool uses an identity that has access to the desired instance of the LocalDB.

Then disable ASP.NET Impersonation in Authentication settings of the application. Otherwise, application uses IUSR_MachineName account to access the database.

This setup may not be suitable for production environment but could be sufficient for database and application development.

Share:
37,983

Related videos on Youtube

allenylzhou
Author by

allenylzhou

Computer science is not a field, it is a lifestyle.

Updated on December 27, 2020

Comments

  • allenylzhou
    allenylzhou over 3 years

    When I try to run my ASP.NET MVC 4 application using Local IIS on Windows 7 with Visual Studio 2013. I run into the following error when the application tries to connect to localDB\v11.0

    Server Error in '/' Application.

    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. )

    The 2 event logs are

    Unexpected error occurred while trying to access the LocalDB instance registry configuration. See the Windows Application event log for error details.

    and

    Cannot get a local application data path. Most probably a user profile is not loaded. If LocalDB is executed under IIS, make sure that profile loading is enabled for the current user.

    Most solutions I found online references this post: http://blogs.msdn.com/b/sqlexpress/archive/2011/12/09/using-localdb-with-full-iis-part-1-user-profile.aspx

    The only difference I see between the described situation and my situation is that the described error code is 0 whereas my error code is 50. However, the proposed solution does not work for me.

    I cannot get past this error even if I set modify setProfileEnvironment to true and I've spent hours of time playing around with different processModel parameters and application pools.

  • shim
    shim over 9 years
    "disable ASP.NET Impersonation in Authentication settings of the application" Where's that?
  • buddybubble
    buddybubble about 9 years
    @shim: its in the iis manager under sites -> <your site> -> Authentication
  • IrishChieftain
    IrishChieftain about 9 years
    Neeraj, what does it matter if site is in WWW or some other folder on server?
  • Neeraj Mehta
    Neeraj Mehta almost 9 years
    @IrishChieftain It doesn't matter but for our simplicity we put it in WWW Folder
  • Danation
    Danation almost 8 years
    This was the easiest and clearest solution. I recommend it.
  • Shrouk Khan
    Shrouk Khan over 7 years
    That was a hard to understand instruction..but it sure worked! :)
  • CAD.Dev
    CAD.Dev over 6 years
    This is not a good idea, please see this answer: stackoverflow.com/questions/5729264/…
  • koviroli
    koviroli almost 5 years
    IUSR_MachineName may be my Machine name? Windows can't find this user.