ASP Session ID

Posted on 2011-05-10
Medium Priority
Last Modified: 2012-08-13
I am using a cookieless session id.  My issue is that every page in my application is assigning a new session id when a page is new page is loaded.

I can't seem to figure out how to use the same active session for every page in the instance.

Question by:gdspeare
  • 4
LVL 13

Expert Comment

ID: 35730226
How are you opening new pages - 1) through links or by typing the urls, 2)in same tab, in new tab or in new window?

If you open different pages in same tab, then everything should work fine. But in different tabs, you may face problem.

Author Comment

ID: 35731061
new pages are opened from the menu in the same tab.

and new session ids are being given.
LVL 13

Expert Comment

ID: 35734364
Then I think that you are using absolute URLs or relative to application root.

I tried it this way: Created two pages Page1.aspx and Page2.aspx in same folder. On Page1.aspx, i added two links to page Page2.aspx as:

<a href="Page2.aspx">Link 1</a>    
<a href="/Page2.aspx">Link 2</a>

If I click on Link 1, it uses the same session id. But if I click Link 2, it assigns a new session id.

I am not sure but it seems that this behavior is by design and probably we cannot change it.
Although its not exactly the solution to your problem, but it will help you understand a bit about cookiless sessions.
LVL 13

Expert Comment

ID: 35734381
Just found on an article that we can use absolute urls like this:

<a runat="server"
    href=<% =Response.ApplyAppPathModifier("/Page2.aspx")%> >Link 2</a>

Here is the link to that post:

LVL 13

Accepted Solution

devlab2012 earned 2000 total points
ID: 35734401
In above comment, remove runat="server".

Try following code:

<a href="Page2.aspx">Link 1</a>    
<a href="/Page2.aspx">Link 2</a>  (Only this gives a new session id)
<a runat="server" href="~\Page2.aspx">Link 3</a>
<a href='<%=Request.ApplyAppPathModifier("/Page2.aspx") %>'>Link 4</a>

Also, see the client side code generated by above code by using View Source option in the browser.


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month13 days, 8 hours left to enroll

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question