Aug 1 2006

HttpResponse.ApplyAppPathModifier Method

Category: ASP.NET 2.0 - GeneralBil@l @ 08:50

A very interesting method I came over today:

HttpResponse.ApplyAppPathModifier

According to the MSDN documentation:

Adds a session ID to the virtual path if the session is using Cookieless session state and returns the combined path. If Cookieless session state is not used, ApplyAppPathModifier returns the original virtual path.

This is very cute!! If you are using cookieless session state, you can easily you this method, give it a virtual path, it will automatically append the SessionId to the URL without any need to do any manual effort!!!

It is also helpful, when you want to redirect from Http to Https or vicaversa, it helps you maintain the same session Id when moving!

This is a small example:

Response.Write(Response.ApplyAppPathModifier("demo/default.aspx"));

will generate something as:

/App/(S(avsbnbml2n1n5mi5rmfqnu65))/demo/default.aspx

Hope this helps!

Regards

Tags:

Comments are closed