HTTP 500 Error for deployed ASP.NET CORE app – works when running locally

500 error when deployed

Object reference not set to an instance of an object.
Problem Id:
System.NullReferenceException at Microsoft.Extensions.DependencyInjection.IdentityServerBuilderConfigurationExtensions+<>c.<AddSigningCredentials>b__10_2

001browser1

This can be tough to diagnose if you are not deployed to Azure [with application insights enabled].  With app insights the message is not real helpful, but a clue lies in the “identityServerBuildConfigurationExtension”

003AppInsights

To verify the issue is with identity server configuration you can update the appsettings.json as shown below and redeploy.  If the site comes up but you can’t access the default “Fetch data” (see image) then this is the source of your problem; identity server configuration.

SNAGHTML952d1a08

in the appsettings.json add the following section:

    "Key": {
"Type": "Development"
}

image

The application will now run [in azure], however this configuration should not be used in a production environment.   The following link provides the steps [links] to “Deploy to Azure App Service”

Note: this fix will allow your site to work if you are deploying to Azure [because it is a secure site using https], however if you are trying to deploy to an ISP using http you'll have some more work because http causes error when deployed

Add comment