Thursday, February 17, 2011

How to change FormsCookieName at runtime in ASP.NET

Hi,

We would like to have the FormsCookieName of FormsCookiePath change per instance of our application. We have an application which has multiple instances on 1 server/domainname. Because of this we can only work in 1 application at the same time, since the cookies will overwrite eachother. Same for the Sessions btw.

Is there a way to dynamicly, for example in the Global.asax Application_Start, change this name? This would be usefull as we keep a license name in each application which could be used as the basis for the CookieName.

We already work with Web.config and extra files to overwrite Web.config values in external files using: <appSettings file="Web.AppSettings.Config">

But this requires manual actions which can be forgotten and are redundant since the settings can be retrieved from the database.

Thanks.

From stackoverflow
  • According to MSDN, the FormsAuthentication.FormsCookieName property that stores the cookie name is a read-only property. This property must be read from the web.config.

    Each instance will need a separate name in the web.config. I suggest including the name of the authentication cookie in your existing change management system.

0 comments:

Post a Comment