Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: ASP
Posted by: Mario Lopes
Added: Dec 11, 2019 5:27 PM
Views: 10
  1. void Application_Error(object sender, EventArgs e)
  2.     {
  3.         var serverError = Server.GetLastError() as HttpException;
  4.         if (null != serverError){
  5.             int errorCode = serverError.GetHttpCode();
  6.             if (404 == errorCode)
  7.             {
  8.                 Server.ClearError();
  9.                 Server.Transfer("notfound.aspx");
  10.             }
  11.             if (500 == errorCode)
  12.             {
  13.                 Server.ClearError();
  14.                 Server.Transfer("ServerError.html");
  15.             }
  16.         }
  17.     }