Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Webpage redirect is not working on exceed file size error

Status
Not open for further replies.

fletchsod

Programmer
Dec 16, 2002
181
0
0
I'm using the file upload in ASP.NET. I noticed when an "exceed file size" error occurred while uploading the file, there I have no way to redirect the webpage after catching this error. This is the script I wrote in global.asax file.

Code:
if (oHttpException.ErrorCode == -2147467259)
{
    Response.Redirect("Error2.aspx", false);
}

So, I did a test script in code-behind on a normal webpage "test.aspx" and tried a webpage redirect and it works (This script doesn't have the file upload parts).

So, the question is was it a "webpage-redirect" issue or a "file-upload error" issue that prevent the redirect from working? I ran the debugger and it showed the global.asax caught the error and passed on the webpage redirect to Internet Explorer 8. So, why am I getting the IE8's built-in error about the loss of Internet connection?

Can anyone help me out?

Thanks...
 
try
Code:
Response.Redirect("Error2.aspx", [COLOR=blue]true[/color]);
if endResponse is false it will continue processing the current request, which you do not want since the file upload error was thrown. true will stop the current response and redirect immediately.

this may cause issues if you are using objects scoped at the request level. this is common with database connection management.

I would also refactor your logic slightly so you know what it means in the future.
Code:
private const int UPLOAD_FILE_ERROR = -2147467259;
if (oHttpException.ErrorCode == UPLOAD_FILE_ERROR)
{
    Response.Redirect("Error2.aspx", true);
}

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
setting it to true had no effect either. I made sure I use full url address this time to avoid the "oh duh!" mistake with the file path. I still get the webpage not found error or internet connection error.
 
So you are getting 2 different errors for the one issue?

Can you identify what event causes which, I would expect an error on redirecting to cause one error consistently..

I assume that there are no other redirects after that one, or if there are that you have confirmed that the code is hitting that specific redirect (I am sure you have, but its the simple things that usually catch me out :$)
 
How can that be? I only have one Redirect() function. For some reason IE didn't get the HTTP Redirect header request, even though it was called in .NET script.
 
you could try [tt]Server.Transfer("Error2.aspx");[/tt] instead of a redirect.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
fletchsod, apologies, I was only trying to rule out the obvious :) From the code sample posted I wasnt able to determine if there were other redirects or not ;).

what are the results of using Server.Transfer?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top