Search code examples
sql-serverasp.net-identityblazor-server-side

.NET 6 Blazor Server side hangs on authenticating user


I am developing a Blazor server side which gets all data from an API; the only connection to a SQL Server is to use Identity authentication with individual user accounts.

It works ok in the development environment but when deployed to IIS, it hangs when trying to access the database, which is hosted on the same server.

I can't get the exact error since the warning thrown says:

Swapping to the Development environment displays detailed information about the error that occurred. The Development environment shouldn't be enabled for deployed applications. It can result in displaying sensitive information from exceptions to end users. For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development and restarting the app.

Anything I tried to set production ASPNETCORE_ENVIRONMENT to development - from other posts unfortunately not specific to server side Blazor over .NET 6 - does not display the real exception and I keep getting that warning.

Does IIS need any further permissions beyond username and password to access the SQL Server database from a Blazor server side app?

How can I temporarily set ASPNETCORE_ENVIRONMENT to "development" for production environment on a .NET 6 Blazor Server side app?


Solution

  • To temporarily display errors in production, you can add this line to the <PropertyGroup> of your main project file:

    <EnvironmentName>Development</EnvironmentName>
    

    But be aware that your production environment will then pick up settings defined in the appsettings.Development.json file.

    Hope this helps!