473,385 Members | 1,279 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Redirect... Not redirecting

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?ImageTooLar ge=true");
}else{
Server.Transfer("ErrorPage.aspx", true);
}
}else{
Server.Transfer("ErrorPage.aspx", true);
}
}

Thanks for your thoughts
Nov 19 '05 #1
1 1083
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.

"Shark Bait" <Shark Ba**@discussions.microsoft.com> wrote in message
news:8E**********************************@microsof t.com...
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?ImageTooLar ge=true");
}else{
Server.Transfer("ErrorPage.aspx", true);
}
}else{
Server.Transfer("ErrorPage.aspx", true);
}
}

Thanks for your thoughts

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Jack | last post by:
Hi, I have a asp result page which shows that a record has been successfully updated. After this display I need to redirect this to a different page. However, I would like to keep the display for...
4
by: Marty U. | last post by:
I have a Session variable I need to check the value of. If it is value a then redirect to some page. I need to implement this in a user control that is on all the relevent pages. I placed the if...
5
by: Alan Silver | last post by:
Hello, I have a page that is supposed to do some checking, and if OK, set a session variable before redirecting to another page. The following code is a simplified version, I have hard-coded the...
5
by: venner | last post by:
I'm having an issue with an ASP.NET website after upgrading to ASP.NET 2.0. The website makes use of a central authentication service (CAS) provided at the university I work for. Each page checks...
15
by: John | last post by:
Hello, I have a php contact script and I want it to redirect to my homepage without using the standard header command. <?php header("location:http://www.johndoe.com/index.html"); exit;
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.