Question

I am writing a .NET application that uses cookies to store a login token. I'd like the user to be able to log into multiple installations of this application on the same server (let's say jacob.local/Devel and jacob.local/Stable), so I want to set the Path property for the cookies appropriately. Currently I'm using Request.ApplicationPath but am running into trouble when the user visits the site with a different case than what I've set up in IIS.

For example, the user visits jacob.local/stable -- the cookie's path will be /Stable, which the browser doesn't send back to me since it can't know that IIS is case insensitive.

Do I have to parse apart the whole query string myself, or is there already a function for figuring out what the path of the application is?

Was it helpful?

Solution

The following trick grabs the application path with casing matched to the one specified in the URL of the current request.

Request.Url.AbsolutePath.Remove(Request.ApplicationPath.Length)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top