I hosted my ASP.NET Core app on IIS (using the publish-in- folder method). I tried to create my own web.config file to see detailed error messages on the client side. So I added file web.config:
<configuration>
<system.web>
<customErrors mode="Off" />
</system.web>
<system.webServer>
<httpErrors errorMode="Detailed" />
</system.webServer>
</configuration>
After I restarted IIS, nothing happened. Clients still got the default error:
Can I somehow get additional information about errors using file web.config?
web.config
<system.webServer>
<httpErrors errorMode="Detailed" />
<aspNetCore processPath="dotnet">
<environmentVariables>
<environmentVariable name="ASPNETCORE_DETAILEDERRORS" value="true" />
</environmentVariables>
</aspNetCore>
</system.webServer>
You can configure it in your Startup.cs
file. By default, it shows the Developer Exception Page only in development mode:
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
If you replace this part just with app.UseDeveloperExceptionPage();
it will always show the detailed error message.
You can read more about it here: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/error-handling?view=aspnetcore-2.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With