Wednesday, June 19, 2013

page error event in asp.net

This event can have error handling code using which user can get some info about the problem.Normally we will create page error event code by redirecting user with that page
protected void page_error(object seender,EventArgs e)
{
Response.Redirect("Error. Html");
}
protected void btn_clikc(object sender,EventArgs e)
{
int a=0,c=10;
int b=c/a;
Response.Write(b.Tostring());
}
Implemented using <custom errors> tag of web.config and also using application _error event of Global.aspx  file
Web.config:
<custom errors mode="on" DefaultRedirect="error.html"></custom errors>
In the same custom error a sub tag called error is present.In this tag we can specify particular error and redirecting
<appsettings>
<connectionStrings/>
<system.web>
<custom errors mode="ReadOnly" default Redirect="error.html"?
<error status code=404" redirect="nofile.html"/>
If user attempts to go for a file which is not present then nofile page will be displayed and for any other if goes to error page.Here we should notice "both files are created by user"
Post a Comment

Bel