Iam trying to handle the unhandled exceptions in my project.I tried with this following code in my web.config file
but it is not at all redirecting to an error page which i have created instead of that it is throwing an exception
in my code itselef.Can anyone suggest me how to handle it.........and how to print the error description over there
in my custom error page.
---------------------------------------------------------------------------------------------------
<sys.web>
......
<customErrors mode="On" defaultRedirect="~/Error.aspx">
</customErrors>
...
</sys.web>
----------------------------------------------------------------------------------------------
And even i tried in Global.asax page in Application_Error() method like below
Exception ex = Server.GetLastError();
Response.Redirect("~/Error.aspx?errmsg="+ex.message);
Server.ClearError();
And in my Error.aspx.cs page i have placed a label and i have written code like this
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text=Request["errmsg"];
}
--------------------------------------------------------------------------------------------------------
But it is not getting redirected my error page and not displaying anything on it....Can anyone suggest me how to fix this. Thanks