How to Debug Response.Redirect losing session variable, when upload file

HELP! I have a page where users can enter text and optionally upload an image. To upload the image, the page contains an image file upload usercontrol I created. The control displays the image after loading and stores the image information to the database and creates an image ID. Then the user can submit the entire page which just saves the user's text and the image ID to the database.

In addition, I create a user account for the user and store their new id in a session variable ("LoginID").

When saved, the page does a response.redirect to the next data input page. Excluding the first page, most of my pages inherit from a basepage class that validates if LoginID exists. If not, it redirects the user to a generic welcome page.

If the user doesn't upload an image, the redirect works fine. If the user uploads an image, then the LoginID is nothing when it gets checked in the basepage PageLoad event for the targe page.

Because LoginID disappears between the redirect and the next PageLoad, I haven't been able to step into where the problem is occurring.

Can anyone tell me how to step through this to find the offending line of code or suggest why I'm having this problem?


7/30/2006 10:31:38 PM 8807 articles. 0 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 1
Get it on Google Play
Get it on Apple App Store


The Response.Redirect function causes a thread abort exception and all the session data is wiped out, it would be better if you store all the user authentication data in either a cookie or the server cache. You can also try setting the optional value of the second param to False, like so:

Response.Redirect("yoururl", False)


Hope this helps.

Osden Pereira
Etihad Airways, Abu Dhabi
8/17/2006 11:57:47 AM

Thank you for the information.

However, I don't understand how/why Response.Redirect causes an exception. It doesn't do it if I don't upload a file. It only happens if I upload the file (which causes a postback) and then submit the page.

Some additional information may show why I now think this is a logic error. The page in question can be used to create a new user account or to edit the user's existing account information. As stated above, when creating a new account, uploading the image causes the session to be lost, not uploading the image preserves the session. But if I use the same page to edit existing information, the session is preserved, whether or not I upload an image.

As far as I can tell, I am executing the same code path in all cases: Response.Redirect. I can't see what I'm doing differently that would cause the abort exception.

Please let me know if you can explain further what I should look for. I understand if you can't. If you have a good link for thread abort exceptions, I would be interested in that as well. Thank you again.

8/17/2006 3:30:51 PM

I found the answer! The initial file upload renames a folder. ASP.NET 2.0's FCN sees this as a change and restarts the application! I found the workaround / infomation in these blogs: and and

9/1/2006 5:42:19 PM

Similar Artilces:

Losing session variables after response.redirect
I'm using StateServer to manage my sessions. <sessionState mode="StateServer" stateConnectionString="tcpip=" /> I then set the session values as follows on one page: Session("UserID") = dbReader("UserID")Session("FirstName") = dbReader("FirstName")Response.Redirect("~/member/Default.aspx") When it redirects to the next page, the session values are blank (null). I'm not sure at all what's happening. The IIS settings are fine as well. XP Pro, ASP.NET 2.0, IIS 5. There are too many protential reasons for session loss, and here is a newly post article on this, whi...

Response.Redirect with Session Variable vs. Global Variable -- Best Practices?
Hi,I have a simple contact form and when the user presses the submit button an email is sent and  I have a response.redirect to "emailSent.aspx" where it says "Your request has been received....etc.".  I have the submit button in a try/catch block.  What I want to do is a "emailFailed.aspx" where it says "Email problem, etc." but I also want to carry over the ex.message text.  I want to pass the ex.error text to the "emailFailed.aspx" page so on pageLoad I can have a label with something like:labelMessage.Text = "There was a problem with your email.  The error is " +...

Losing Session variables/state?
I'm having regular issues with the ASP.NET 2.0 Sessions. The session variables work fine for the most part. I found, downloaded and installed a Session timeout control which is intended to resend the user to the login page when the session timeout is reached. This does work but I'm not sure how well. The control is installed on various Master Pages.  The problem is that from time to time I get an Object reference not set to an instance of an object error:if (DetailsView1.CurrentMode == DetailsViewMode.ReadOnly) { string session = Session["client_id"].ToString(); DetailsView1.F...

Microsoft Chart control for .NET Framework about state management and serialization problem, it works OK with one XML file but fails with another XML file
I use Microsoft Chart control for .NET Framework , you can see details at The Chart1 is load data from a xml and save to ViewStateData, so even if after I click Reload button, the chart1 still display OK! I'm very strange that the chart1 works well after click Reload button if it's loaded from Chart1.Serializer.Load(HttpContext.Current.Server.MapPath("~/Template/1.xml"));but chart1 don't display fter click Reload button if it's loaded from Chart1.Serializer.Loa...

Session State variable missing after Redirect
When an error occurs, I set a session variable so that after redirecting to an error page, a detailed explanation can appear.  The variable (a string) is gone by the time I reach Page_Load in the target page.  I've checked and it is the same session ID. Any ideas? Are Sessions enabled? Are you forwarding to a page outside of you application?View My Blog Download My URL Rewriter and Reverse ProxyOnly $9.95/month, ASP.NET, 2GB & SQL 2005...

Response.redirect loses session info
Hi - I am running a site which checks available slots on a normal web site, and then if the user wants to book a slot, redirects them to a page behind SSL where they can enter their Credit Card details. I use response.redirect to take them to the SSL page (as server.transfer will not show them the padlock etc - so I think this may put people off entering those details) - and I store the information the person was looking for in a session variable. However, when I response.redirect, the session loses it's information. Is it correct that sessions only exist in the same applica...

Session Variables lost after Response.Redirect()
Hi gurus,  I encouter lost session variables trouble when Response.Redirect() to another aspx page. I set 19 Session variables before redirecting. However, the redirected page's session contains only One variable. The very weir sympton is: If I restart IIS, only for the first IE encounter, the redirected page DOES show all 19 session variables.Once I close IE, any further IE or IE from any other machine's only shows ONE session variable. I can also reproduce such symptons in VS2005 development environment. Can someone tell me what I have missed?   Thanks! Here is ...

session variable gets empty after response.redirect
 Hi,I am not getting why following things happening.. 1. I have declared session variable in global.asax2. Session("postrentattempt") = ""3. In the page load of post rent page I am writing           Session("postrentattempt") = "1"            Response.Redirect("sellerlogin.aspx")  4. Now, in sellerlogin, I am checking if             Session("postrentattempt") =...

Flash file upload.. no access to session variables
Hey guys I'm witting a pretty simple web app, and I wanted to add multiple file upload functionality.  Well after much searching I came across a couple different solutions and for now I'm working with MultiPowUpload from element-it; the setup was quick and simple and seemed to work pretty well.  It is written in flash and when each file is uploaded the contents are sent to an aspx page in the background and the contents are fetched with an HttpPostedFile call.  The problem is when the call is made to that page I'm unable to access any session variables, it's as...

State management upon session variable changes
I noticed that whenever a session variable is changed...the application knows about it and suddenly restarts session. My question is does restart "ALL" sessions or only the active sessions for which the variables changed? Imagine a "multi-user" application all with different states and an administration panel that lets you change session variables.  In this case, my question has to do with the question that if Company X changes his session variables, will only Company X's sessions be reset or will all "sessions" be reset?  Hope that makes sense. ...

File upload control breaks response.redirect
 I have a page where I test for the user pressing the refresh button on their browser.  If they refresh I want to redirect them to an error message page.  Its all good until I add a file upload control on my page... then it dosent work.Note that I'm not actualy using the file upload control.  This post is not about handling errors with the file upload control.  The problem I'm having is handling a page refresh which is detected by code in the basepage class.  A sample page follows.  To reproduce the error, load the page, click the Click Here link, t...

Posting filepath in file upload control in .NET to the next page and uploading the file from second page
In our application (using C# .NET) there is a form with file upload options. After filling up the form details, the summary of the details need to be shown in the next page before committing the information into the database. Right now, Server.Control is used to transfer the contents to the next page and the form details are retrieved using Request.Form["control id"]. But this is not working for File upload control alone.File upload can not be done in the first page itself, as the foreign key in File upload table gets updated only in second page after confirmation. Therefore, is th...

Can writing a file cause you to lose session variables?
I am writing a form that allows people to search through the database, choose some records and then after clicking a button, populate a spreadsheet.  What seems to happen after the first time on the form is that the app times out because on the next search, I am taken back to the login page. This is due to some logic in master page where I need to send them there if they have logged out.  Here is the code in the master page: If Session("sessionid") Is Nothing Then HyperLink1.NavigateUrl = ""Response.Redirect("default.aspx") ElseSession("...

losing Session Values with Response.Redirect(NewPath, False)
 Hi All,  I noticed you responded to a similar post to the problem I am having. Basically I have built my own URL rewritting app that accepts a url such as http://www.someserver/com/mypage.aspx?editmode=true an based on this it does some checks (In On Application_beginrequest or global.asax) to see if the user should be logged in or not to access the page. If the user does need to be logged in, it will automatically redirect them to the login page and request that they log in.The trouble I'm having is that on the login.aspx when the user logs in and their credential...

Web resources about - How to Debug Response.Redirect losing session variable, when upload file -

Frequency response - Wikipedia, the free encyclopedia
Frequency response is the quantitative measure of the output spectrum of a system or device in response to a stimulus, and is used to characterize ...

Antibodies to our own proteins may predict adverse vaccine responses
(credit: Art Writ ) Let's get something straight from the start: vaccines are good. Let's be completely clear about that. But sometimes some ...

GOOD NEWS: Apple Buys Technology That Uses Your Phone’s Camera to Gauge Emotional Response to Ads
... better understand consumer reactions to engagements. Given the iPhone’s camera, the possibilities seem endless: • Gauge the emotional response ...

Five possible responses to the Google-Motorola merger
When big acquisitions are announced, there's likely an aftershock that reverberates through an industry. CNET takes a look at some possible scenarios ...

Giuliani Says Trump’s Response To Hillary Calling Him A ‘Sexist’ Was ‘Politically Brilliant’
Giuliani Says Trump’s Response To Hillary Calling Him A ‘Sexist’ Was ‘Politically Brilliant’

Abbreviated pundit roundup: 'A national crisis like this demands a national response'
... Barack Obama , who held a live town hall on CNN on reducing gun violence yesterday: A national crisis like this demands a national response. ...

Catcher cuts capex for 2016 in response to client orders
Catcher Technology is planning to cut its capex for 2016, and the amount will be much lower than those budgeted in the past two years in response ...

Amy Schumer Has the Perfect Response to Talk About Her New Boyfriend: This is Apparently My 'Biggest ...
Amy Schumer Has the Perfect Response to Talk About Her New Boyfriend: This is Apparently My 'Biggest Accomplishment'

Consumers Dissatisfied With Interactive Voice Response
Often, respondents reported being frustrated by interactive voice responses (IVRs) that replicated information already available on the website. ...

No more 'red lines'? Chinese, N. Korean aggression tests US response
No more 'red lines'? Chinese, N. Korean aggression tests US response

Resources last updated: 1/11/2016 5:41:18 AM