I have a call to method DoSomething() in my page load event:
protected void Page_Load(object sender, EventArgs e)
{
try
{
DoSomething();
}
catch
{
Server.Transfer('~/Error.aspx');
}
}
Now problem is DoSomething also does a Server.Transfer to Error.aspx if some condition is not met and meanwhile if my Page_Load also throws exception, that also does a Server.Transfer.
Now I get duplicate error pages shown in browser.
How do I stop this?
I want that no matter if I write Server.Transfer 5 times, it should only show the error page once and not show duplicate pages in 1 page.
hmm.. how about DoSomthing() should return a boolean that tells you if it already issued a server transfer?
And ofcourse your “DoSomthing()” method should look somthing like that: