Hello all, I am having a problem with my discountasp.net hosted account where Session state is being lost immediately. If I create a Session variable on page load and then a postback event (such as a button click) is fired, the Session variable is empty. Also, Session variables are lost when stored on one page and later retrieved on another page. An example of this would be All items in a shopping cart are stored in session, they then view the shopping cart (and the items are still there) and then once the user clicks checkout, the Session holding the items is lost on the confirmation page in the checkout process... Here is example code that I have which is causing the issue: On page load a session variable is created and then server side validation makes sure that the entered string equals the stored Session variable. Code: PageLoad(...) { if (!IsPostBack) SetUpCaptcha(); } private void SetUpCaptcha() { //create random string and store it in session here Session["Captcha"] = randomValue; } protected void cvCaptcha_ServerValidate(object source, ServerValidateEventArgs args) { string validString = (string)Session["Captcha"]; if (args.Value == validString) //validString is empty.. args.IsValid = true; else { args.IsValid = false; SetUpCaptcha(); } } This code works perfectly on my development machine, as well it works perfectly on our testing server, and it works perfectly fine on my GoDaddy hosted account. The only things that I have different on my discount asp account are in my web.config file: Code: <httpCookies requireSSL="true"/> <!-- I have also tried removing this code, and keeping it and neither has been helpful: --> <sessionState mode="InProc" cookieless="UseCookies" regenerateExpiredSessionID="true" timeout="30" /> Is there something that I missing about how discountasp.net Servers maintain Session state that I am missing which could be causing this error? I doubt that it's faulty code since it works in 3 other environments.. But I'm really not sure at thing point. Thanks
Do you have a domain name assigned to your discountasp.net account? Take a look in the asp.net 3.5 forum here under a post I posted here called "Losing Session Varaible " It might be the same thing I was running into. Hope that helps... Miro
Still No Luck Yes I have a domain name associated with the Account. I tried adding that header in global.asax begin_request that your post recommended, it has not done anything to solve this issue. Is there something different that discountasp.net does with Session that I'm not aware of? Because the Session state works perfectly fine in dev, test, and on a godaddy.com production server. For example, is dicountasp.net using a web farm to host the site or something that maybe the requests are going to different servers and therefore my session isn't sticking? Thanks, Shawn
If by "web farm" you mean load balancing between multiple SQL servers, no. The web server and SQL server are on separate boxes, but that would not affect your session variables. You might want to check out this Knowledge Base article.
Is there something else I may be missing? Is there something else I may be missing then? If I am using InProc to store session right now, then why is it not working on discountasp.net but working fine on godaddy? Thanks, Shawn