Coding Villa Forum
FAQs
Advertisements

How to avoid or disable Session in another tab in asp.net?

Sagar Online 8/1/2012 12:22:21 PM

Respected Sir,

I an desgning an asp.net application with multiple tabs interface. For that application I want to disable session at new tabs. So, how to avoid session in another Tab. Means i have Login & have session id, and suppose I have created another tab it gets logged session.  I want to avoid  that logged session in another tab.

Thanks & Regards,

SAGAR

Share with Friends

Advertisements

Answer

Iram Online 8/2/2012 3:55:46 PM

Identify page request per tab(uniquely) which help server to interprit the request

as unique request for new tab even though it is for same record. In fact there are

many ways we can achieve this in Asp.NET.

First Solution. The Simpler Solution:
You can change config settings of Asp.NET site as following. or


regenerateExpiredSessionId="true" />


As you show, the value “UseUri” of cookieless attribute with sessionstate tag is

set. This indicate to use cookieless session and in particular embed session

identifying code into the URI. So each tab you open contains unique code for

identifying the request as unique request in URI itself. The unique code is

appended before the page name.

i.e. http://www.abc.com/SampleWebSite/(S(afdg3ires1ik0lmjm3pkjtzl))/Home.aspx

The only cons of this solution is that the URI is then distorted with some unique

code. So user can not use it for bookmarking or promoting site. It is not

generating bookmark friendly.

Second Solution. Manually generate unique page identification code and insert it

into hidden field on every page.


In the form load include following code. It will generate unique page

identification code based on millisecond and other time component which always be

unique for your site.

If Not IsPostaback Then
'Generate a new PageiD'
Dim R As New Random(DateTime.Now.Millisecond +
DateTime.Now.Second * 1000 +
DateTime.Now.Minute * 60000 +
DateTime.Now.Minute * 3600000)
PageID.Value = R.Next()
End If
So by this method you can identify each tab request as unique requests. But it has

following two disadvantages.

First: The access of hidden element PageID is only when ViewState is restored on

postback. So you cannot access PageID in page_init().
Second: As hidden field is accessible to the visitor, anyone can change PageID. So

this solution will work only for environment with 100% trust ratio of all user.

Answer

Saad Online 8/24/2012 2:49:17 AM

Thanks for detailed answer.
Share with Friends

Post reply

 

Enter This Code
Captcha
 

Subscribe

Email me when people reply


Subscribe to the