Skip Asp.Net standard error screen

I have an application that you need to register in db to connect to it, but if you haven’t done this, there is an error screen, but it really looks ugly, as you can see

enter image description here

I tried to check if the session in which the user id, == null and clear content was saved was saved, and this is on the start page where every user connects first

if (this.Session["SessionId"] ==null) { Response.ClearContent(); Response.Write("ERROR"); Response.End(); } 

Why am I getting an error here

  <system.web> <customErrors defaultRedirect="~/Error/Error.aspx" mode="Off"/> </system.web> 

Thanks for the help and quick reply.

+4
source share
1 answer

Turn on your application’s CustomErrors mode in web.config and provide a page for errors. You will need to set the defaultRedirect property for unhandled errors.

 <customErrors defaultRedirect="url" mode="On|Off|RemoteOnly"> <error statusCode="statuscode" redirect="url"/> </customErrors> 
+7
source

All Articles