Arun Rana
Arun Rana

Reputation: 8606

Session issue with chrome in MVC3

I have used session to store some config setting in MVC3 application, in my case i have made another class called sessionhelper to maintain session property with get and set property on app_code folder as per below

 public static string IsPaypalSupport
        {
            get
            {
                if (System.Web.HttpContext.Current.Session["IsPaypalSupport"] == null)
                {
                    //if session is expired then redirect to home page


                }
                return Convert.ToString(System.Web.HttpContext.Current.Session["IsPaypalSupport"]);
            }
            set { System.Web.HttpContext.Current.Session["IsPaypalSupport"] = value; }
        }

On Home page (homecontroller) i set this property to true and redirect to inner page now , in inner page's controller i have used this property set viewbag as per below

ViewBag.SupportPaypal = bool.Parse(app_code.SessionHelper.IsPaypalSupport.ToString());

Now when i hit F5 then it will call again,
In Firefox session value still available so it will return correct value but
In Chrome session value will be null so error

Why every request in chrome will make session to null?

How i need to handle this null session , i would like to put redirection to home page (index of home controller) whenever session is expired so how can i do it in sessionhelper class?

thanks in advance.

Upvotes: 1

Views: 1510

Answers (2)

amit patel
amit patel

Reputation: 2297

 <sessionState cookieless="true"  mode="InProc" timeout="30" > </sessionState>

Try this, will work in CHrome

Upvotes: 1

x2.
x2.

Reputation: 9668

Maybe cookies is turned off in chrome or it setted not to domain but for some folder or subdomain.

Upvotes: 1

Related Questions