question

dsbdev-7403 avatar image
0 Votes"
dsbdev-7403 asked DuaneArnold-0443 answered

Hide the IIS errors when a .NET Core app can't start

We have a .NET Core 5 Web Api hosted in IIS. I understand that under certain conditions (internal to our app), the process will fail to start.

In such cases, we get a detailed error page from IIS that the application failed to start. Security reviews frown on such information being disclosed. There are many controls in place for not showing "detailed error pages" in ASP.NET, are there any similar controls for .NET Core apps hosted in IIS?

dotnet-aspnet-core-webapi
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

See the official docs. Make sure you are not showing the developer exception page. Share your startup.cs code if you are still having issues.


0 Votes 0 ·

Not using UseDeveloperExceptionPage.

0 Votes 0 ·
DuaneArnold-0443 avatar image
0 Votes"
DuaneArnold-0443 answered dsbdev-7403 commented

@dsbdev-7403



And why can't the program start? And is there an exception being thrown? And this is a WebAPI program, a Web service, you are talking about?

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

It's a Web Api. Generally startup issues are config file errors, can't connect to database, etc. Just wondering if there's a way when it starts, not to express .NET and IIS details.

0 Votes 0 ·

e.g.

HTTP Error 500.30 - ASP.NET Core app failed to start
Common solutions to this issue:
The app failed to start
The app started but then stopped
The app started but threw an exception during startup
Troubleshooting steps:
Check the system event log for error messages
Enable logging the application process' stdout messages
Attach a debugger to the application process and inspect
For more information visit: https://go.microsoft.com/fwlink/?LinkID=2028265

0 Votes 0 ·
DuaneArnold-0443 avatar image
0 Votes"
DuaneArnold-0443 answered

I don't see why you can't implement global exception handling and logging that can be invoked during WebAPI start up in Startup.cs

https://stackify.com/csharp-catch-all-exceptions/

Below is WebAPI implementing GEH and logging with Serilog and the ErrorHandlngFilter.cs stating at Program.cs

https://github.com/darnold924/PubCompanyCore3.x/tree/master/WebApi

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.