views:

54

answers:

2

Is there some method in asp.net for getting an absolute url with cookieless session?

UPDATE: I need create other new URL. It is not requested URL.

I´m using Response.ApplyAppPathModifier for getting relative URL with cookie session.

Thx in advance,

+2  A: 

I tried Request.RawUrl and Request.Url (and its properties in the Immediate window).
None did show the extra attribute the setting (web.config):

<sesionState cookieless="true" />

makes in the url.

Example

http://localhost:2677/WebSite1/(S(3abhbgwjg33aqrt3uat2kh4d))/cookielesssessiondetection.aspx

However if you're after that part, 3abhbgwjg33aqrt3uat2kh4d, you can get it via:

Session.SessionID

Update after the updated question:

I put in my test application a Hyperlink control on the page. In code behind, Page_Load, I added:

HyperLink1.NavigateUrl = Response.ApplyAppPathModifier("About.aspx");

When I run that page then the url to About.aspx gets set with the cookieless session part included.

When I check the source of the rendered html in my browser I see this:

<a id="HyperLink1" href="/WebSite1/(S(3tzgdnmhwxmxqer10d11auuq))/About.aspx">HyperLink</a>
XIII
UPDATE: I need create other new URL. It is not requested URL.
fravelgue
Yes, this is a relative URL, but i need Absolute URL, i´m using string.format for getting domain. But i hope to exist one especific function. Thx for you help.
fravelgue
I don't think there's a specific function out of the box. However you can make a completely new Uri instance and pass in the pieces with some string formatting on the Request.Uri property.
XIII
A: 

Did you try Request.Url.ToString(). It should work for you. If you needed was the url of another page on your site then you can proceed like this...

String url = new Uri(Context.Request.Url, ResolveUrl("~/ABC.aspx")).ToString )

We also have something like Request.Url.AbsoluteUri

I hope One of the above should work for you.

prabhats.net
I don´t know why. But ResolveUrl not work with cookieless URL.
fravelgue