Blazor CRUD Sample: HTTP Error 500 for the request on IIS Server blazor c# iis


I just published my Blazor CRUD example to the local server. Website is working well, but I get HTTP Error 500 when I go to the fetch data page. Everything works well when I run on the Visual Studio, but IIS server. I have the connection string in context file. I also edited the connection string on the Application Pool settings page, but still not working.

This is the code piece I am using on the context file:

        optionsBuilder.UseSqlServer(@"Data Source=(LocalDb)\MSSQLLocalDB;Initial Catalog=master;Trusted_Connection=True;");

I also use this connection string for the IIS: enter image description here

8/10/2018 2:46:33 AM

Accepted Answer

The answer is that there are two different LocalDB instances here. Unlike SQL Server Express instances, which are running as Windows services, LocalDB instances are running as user processes. When different Windows users are connecting to LocalDB, they will end up with different LocalDB processes started for each of them. When we connect to (localdb)\v11.0 from Visual Studio, a LocalDB instance is started for us and runs as our Windows account. But when Web Application, running in IIS as ApplicationPoolIdentity, is connecting to LocalDB, another LocalDB instance is started for it and is running as ApplicationPoolIdentity! In effect, even though both Visual Studio and Web Application are using the same LocalDB connection string, they are connecting to different LocalDB instances. Obviously the database created from Visual Studio on our LocalDB instance will not be available in Web Application's LocalDB instance.

Easy fix is using SQL Server Express instead of LocalDB

More details -

8/10/2018 2:58:12 AM

Related Questions

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow