Prakash
Prakash

Reputation: 235

how to maintain session for 2 different browsers?

I done project in ASP.net MVC3. In my project i create a session as follows in Home Controller

if (Session["ulclass"] == null)
     {
                    Session["ulclass"] = "list";
     }

I use this session to my Product List page.. as a class for div tag as follows..

<div id="listheading" class="listHead" @if (Session["ulclass"].ToString() == "grid")
                                       {
                                           <text>style = "display:none;";</text>
                                       }>

When i copy this Productlist URL from FireFox to Chrome... session value not come.. it produce the error...

Can any one help this ?

Upvotes: 0

Views: 1137

Answers (2)

Srinivas
Srinivas

Reputation: 1

Use Convert.ToString(Session["ulclass"]) == "grid" to avoid error first, and then add in we.config

Upvotes: 0

Guffa
Guffa

Reputation: 700192

You can use cookieless sessions. That way the session id is sent in the URL instead of a cookie, so then you could just copy the URL anywhere and you are still in the same session.

Put this in web.config:

<sessionState cookieless="true" />

(The drawback is of course that anyone can copy the URL anywhere and still be in your session...)

More about cookieless session: http://msdn.microsoft.com/en-us/library/aa479314.aspx

Upvotes: 1

Related Questions