asp.net-coreexceptionrazor-pages

How to get a server exception to display on a Razor Pages error page


I have a redirect page whenever an error occurs named error.cshtml, but I am not sure how to access server errors to be displayed on this page for remote trouble shooting. I know it's bad practice to display such info but its only temporary. Any ideas?


Solution

  • If like me you wish to view server side errors on a deployed Razor Page application, you can add app.UseDeveloperExceptionPage() in your Configure method of the Startup.cs file. This is enabled by default if you are running in dev mode.

    Be warned however; this will display all exceptions that occur on your website to anyone.