Redirect... Not redirecting

G

Guest

The code below is in my global.asax. When a user uploads a file that is to
big it catches the error and tells the user the problem. For some reason the
redirect never happens. When steping through the code it does step into the
redirect but continues to the next line like nothing happened and it does NOT
redirect! Any ideas why this would happen?

The code... (thanks Mike Gunderloy)...
protected void Application_Error(Object sender, EventArgs e){

if(Path.GetFileName(Request.Path) == "PictureManager.aspx"){
System.Exception appException = Server.GetLastError();
HttpException checkException = (HttpException)appException;
if(checkException.GetHttpCode() == 400 && checkException.ErrorCode ==
-2147467259){
// Error 400 = bad request, user
// tried to upload a file that's too large
Server.ClearError();
Response.Redirect("PictureManager.aspx?ImageTooLarge=true");
}else{
Server.Transfer("ErrorPage.aspx", true);
}
}else{
Server.Transfer("ErrorPage.aspx", true);
}
}

Thanks for your thoughts
 
O

Ollie Riches

are far as I know you have to call Server.ClearError() before attempting a
redirect or transfer. If you don't the framework will attempt to redirect to
your defined error page or the default error page

--
HTH

Ollie Riches
http://www.phoneanalyser.net

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a programmer
helping programmers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top