Session ends when debugging ASP.NET, but works fine on dev and test server

I had a strange problem when a session ends after a postback, when I debug it in visual studio 2010.

I store the variable in the session on the first page. It retains its value on the next page, but after that it is lost. It returns a null value. The strange thing is, when I copy the exact code to dev or test servers, it works fine ...

Any ideas what could happen? Thank you

UPDATE
The code is pretty simple. I have a default.aspx page where I set the session variable:

HttpContext.Current.Session["PurchaseOID"] = purchaseOID; 

When I click Next, the Default.aspx page redirects it to the Information.aspx page. Additional user information is collected on this page (using the DevExpress controls). When I click Next on this page, the PurhcaseOID session variable returns null when the page loads.

 protected void Page_Load(object sender, EventArgs e) { if(HttpContext.Current.Session["PurchaseOID"] == null){ throw new Exception("error!"); } } 

Oddly enough, the session is saved when the page loads for the first time. But in postback, it loses its variables. Also, this is what JUST started to happen. I have been working on this code for a month or so, and it works fine. When I deploy this exact code to our dev or test server, it works fine.

I am debugging this in Cassini. Help will be greatly appreciated, thanks!

Shahzad Chaudhary

+4
source share
2 answers

I realized it was a stupid mistake. This change occurred in the Global.asax Application_Error method. For some reason, when I set a breakpoint, it didn't hit.

0
source

When you testing, have you turned off cookies? I ask because the session identifier is stored in a cookie if you do not use cookieless sessions (rarely). Therefore, if you turned off cookies in your browser in a test environment, it will not be able to get session values. I do not believe that this causes errors in their storage.

+1
source

Source: https://habr.com/ru/post/1334138/


All Articles