Introduction:
SQL server express LocalDB is a developer's database, which is a lightweight edition of Microsoft SQL. It works as same as SQL with fewer features.LocalDB can be created and managed by VisualStudio or SQL management studio. Using visual studio we can create database LocalDB either from "SQL Server Object Explorer" or by using code first approach using any asp.net web application.
To configure LocalDB to an application hosted in local IIS, we need to set up a few additional settings. Here we are going to discuss the common problems and solutions while configuring.
Create ASP.NET Core MVC Sample Application:
Create asp.net MVC Dotnet core application. In VisualStudio, while selecting an MVC application template we can select the authentication option, in that select individual login option.After the project creates initially run the application using IIS Express server which is a prebuilt server in VisualStudio.
We can observe a sample application with few pages like registration and login. Now register a new user in the application. After hitting the register button using code first approach new database gets created in the LocalDB. The created database can be seen as below
Local IIS Hosting And Domain Binding:
Now host this Dotnet core MVC application to our local IIS. Click here steps to follow local IIS hosting.Now here I'm using my local domain as "http://testmyapp.com", check for the above link for how to bind domain in local IIS. Now run the application by navigating to "http://testmyapp.com" in the browser
Access LocalDB By The Application Hosted In Local IIS:
Now we are able to run the application, in local IIS which is using LocalDB as a database. Now try to login with your registered credentials. we are going to see the error page as below."Error about like database can't be found or login failed".
This error looks like explaining as a generic error, not giving much clarity. So now open "Event Viewer" in your system open event viewer => windows log => Application and then select an error is listed as follows
Resolve Profile Not Loaded Issue:
Error at windows log shows"Cannot get a local application data path. Most probably a user profile is not loaded. If LocalDB is executed under IIS, make sure profile Loading is enabled for the current login user"
To fix this problem go to "C:\Windows\System32\inetsrv\Config" folder and open "applicationHost.config" file as below
Inside "applicationPoolDefaults" tag change the attribute "setProfileEnvironment="true" set to true and save.
not working
ReplyDeleteworked fine for me. If it does not work for you, they are might be other errors within your request pipeline.
ReplyDelete