How to determine the .NET cookie path .NET

I am writing a .NET application that uses cookies to store a login token. I would like the user to be able to log into multiple installations of this application on the same server (say jacob.local/Devel

and jacob.local/Stable

), so I want to set the Path property for cookies correctly. I am currently using Request.ApplicationPath

, but I am having problems when a user visits a site with a different case than what I configured in IIS.

For example, a user visits jacob.local/Stable

- the path to the cookie will be /Stable

, which the browser does not return to me since it cannot know that IIS is case insensitive.

Do I need to parse the whole query string myself, or is there already a function to figure out which path to the application?

+2


source to share


1 answer


The following trick grabs the application path with a corpus that matches the one specified in the url of the current request.



Request.Url.AbsolutePath.Remove(Request.ApplicationPath.Length)

      

+5


source







All Articles