Sureder Rawat
If we have asp.net application which consist 100 web pages and we want to write a customized error handler for handling the http code error then write the two step that must be take.
By Sureder Rawat in ASP.NET on Aug 03 2006
  • Prince sahni
    Oct, 2007 24

    In a global.asax file put the application_error event

    protected void Application_Error(object sender, EventArgs e)
            {
                Server.Transfer("ErrorPage.aspx");//this will show customized error page
            }

    In the ErrorPage.aspx.cs file you need to write this code

    Exception ex = HttpContext.Current.Server.GetLastError().GetBaseException();

                errMessage = ex.Message.ToString();
                errInnerException = ex.ToString();
                errStackTrace = ex.StackTrace.ToString();

                Server.ClearError();
                Response.Write(ErrMessage); //displays the last error

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS