Hello, I'm trying to catch an null ref exception if the url that the page that enter in does not exist. here is my code:
if (sName.Length > 0)
{
//Get Id From Name
sId = ((Int32)db.ExecuteScalar(d
b.GetSqlSt
ringComman
d("Select Id From v_Navigation Where Name = '" + sName.Replace("|", "").Replace("'", "''") + "'"))).ToString();
}
If Id does not exist it will throw an error but I want to redirect to the home page. I want to use a try catch but I don't know where to put it.
Start Free Trial