Monday 9 January 2017

Set Custom error page for all Application label error and error code also

//  IN Global.asax Under Application_Error

void Application_Error(object sender, EventArgs e)
    {
        //////////// Code that runs when an unhandled error occurs

        //Response.Redirect("~/Error Page Not Found");

        Exception ex = Server.GetLastError();
        Application["TheException"] = ex; //store the error for later
        Server.ClearError(); //clear the error so we can continue onwards
        Response.Redirect("~/Error Page Not Found"); //direct user to error page

    }



// IN web.config file Under

  <system.web>
<!--<customErrors mode="Off"></customErrors>-->
<customErrors mode="RemoteOnly" defaultRedirect="~/Error Page Not Found"></customErrors>

  </system.web>

<system.webServer>

    <httpErrors errorMode="Custom" defaultResponseMode="Redirect">
      <remove statusCode="404" subStatusCode="-1" />
      <error statusCode="404" prefixLanguageFilePath="" path="~/Error Page Not Found"
       responseMode="Redirect" />
    </httpErrors>

    <validation validateIntegratedModeConfiguration="false"/>

</system.webServer>

No comments:

Post a Comment

Excel Sort values in ascending order using function TEXTJOIN

 Excel ::  Text ::  1,3,5,2,9,5,11 Result :: 1,2,3,5,5,9,11 Formula ::     TEXTJOIN ( ",",1,SORT(MID(SUBSTITUTE( A1 ,","...