Blazor CRUD Sample: HTTP Error 500 for the request on IIS Server

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Blazor CRUD Sample: HTTP Error 500 for the request on IIS Server



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




1 Answer
1



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 - https://blogs.msdn.microsoft.com/sqlexpress/2011/12/08/using-localdb-with-full-iis-part-2-instance-ownership/





now I understand how it works. I used SQL Server Express, gave the permissions and it worked like a charm! thank you so much!
– winnervswinner
Aug 10 at 3:12






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard