Context:
I want to upload multiple files but when max request size mentioned in the web.config file is exceeded, I get a timeout page in IE. To handle this i have overridden the Page.OnError method and it gets executed quite well but I don't get the desired result
Desired Result: redirect to DefaultErrorPage
I have already tried handling error in the Global.aspx, created default error page and configured it in the web.config file but nothing worked :(
Here is the code of OnError method:
protected override void OnError(EventArgs e)
{
HttpContext ctx = HttpContext.Current;
Exception exc = ctx.Server.GetLastError();
ctx.Server.ClearError();
ctx.Server.Transfer("DefaultErrorPage.aspx");
}
Please help its urgent
Thnx in advance for your time and help
EDIT =======================
Thanks MalikRizwan for your time and effort
But after thorough search I found out the following thing(s):
When we upload multiple files or a single file or in any way if our request size exceeds masRequestSize defined in the web.config, we can't handle it at any level or in any try/catch block.
And why is that so ? Because IIS has to first suck up all the content and then after that the control passes to asp.net but remember the request size exceeded the maxRequestSize therefore, IIS cannot process the request, so it just ends the request (and as the request has ended therefore Request.Redirect()/Server.Transfer() won't work neither do the custom error page node defined in web.config) and the client sees white page of death (i mean timeout page)
The only solution I think is to use Flash/AJAX
I hope this will save lots of efforts by the people out there