I have a simple function GetPageName(String PageFileName, String LangCode)defined inside a class file. I call this function from a file default.aspx.cs. In this function, I cannot use Response.Redirect("Error.aspx")to show the user that this error has been generated.
Below is a sample code
public static string GetPageName(String PageFileName, String LangCode)
{
String sLangCode = Request("Language");
String pgName = null;
if ( sLangCode.Length > 6)
{
Reponse.Redirect("Error.aspx?msg=Invalid Input");
}
else
{
try
{
String strSql = "SELECT* FROM Table";
Dataset ds = Dataprovider.Connect_SQL(strSql);
}
catch( Exception ex)
{
response.redirect("Error.aspx?msg="+ex.Message);
}
}
return pgName;
}
I have a function defined in Business and Datalayer where I want to catch an error and redirect the user to the Error page.
source
share