Author: guyind | Posted on: 2/22/2009 9:19:14 PM | Views : 259

Hi there
I am new to asp.net 2.0 . I would like to know if we can use response.redirect inside a catch block.
Here is the code. It isn't returning value in query string.

SourcePage.aspx
public void ErrorValidate()
{
try
{
int a = 10;
int b = 0;
int z = a / b;
}
catch (Exception ex)
{
Response.Redirect("ErrorPage.aspx?error="+ex.Message.Replace("\r",""));
}

finally
{
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ErrorValidate();
}

}

ErrorPage.aspx

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Request.QueryString["ex"] != null)
{
string lbl = Convert.ToString(Request.QueryString["ex"]);
...

Go to the complete details ...