What will happen is if there were any page named 1.aspx it will be redirected else
it will result in 404 page not found
in what code uve specified.
but when u try to catch server error then u can try redirecting.
and there is no point in using finally in this screnario.
ill put one best example where we use all these three
SqlConnection conn2 = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
public DataTable ExecuteSql(string sql)
{
DataTable dt = new DataTable();
try
{
DataSet ds = new DataSet();
conn2.Open();
SqlDataReader rdr;
SqlCommand cmd = new SqlCommand(sql, conn2);
cmd.CommandTimeout = 60000;
cmd.CommandType = CommandType.Text;
rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
dt.Load(rdr);
return dt;
}
catch(Exception ex)
{
throw ex;
}
finally
{
conn2.Close();
}
}
Exception ex = Server.GetLastError();
HttpException httpEx = ex as HttpException;
if (httpEx != null && httpEx.GetHttpCode() == 404)
{
}