I have an error.aspx page. If a user comes to that page then it will fetch the error path in page_load() method URL using Request.QueryStrin
Check for the value of the parameter:
// .NET < 4.0
if (string.IsNullOrEmpty(Request.QueryString["aspxerrorpath"]))
{
// not there!
}
// .NET >= 4.0
if (string.IsNullOrWhiteSpace(Request.QueryString["aspxerrorpath"]))
{
// not there!
}
If it does not exist, the value will be null, if it does exist, but has no value set it will be an empty string.
I believe the above will suit your needs better than just a test for null, as an empty string is just as bad for your specific situation.