如何改变FormsCookieName在ASP.NET运行时 [英] How to change FormsCookieName at runtime in ASP.NET
问题描述
我们希望让每个我们的应用程序实例的FormsCookiePath的FormsCookieName变化。我们这对一台服务器/域名多个实例的应用程序。正因为如此,我们可以在1个应用程序在同一时间只能工作,因为饼干将覆盖海誓山盟。同为BTW的会话。
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.
有没有办法来动态地,例如在Global.asax的Application_Start,改这个名字呢?正如我们在它可以用来作为CookieName基础每个应用程序保持的许可的名称,这将是有用的。
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.
我们已经与Web.config中和额外的文件工作,利用覆盖在外部文件Web.config中值:<文件的appSettings =Web.AppSettings.Config>
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.
感谢。
推荐答案
据<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.formscookiename.aspx\"相对=nofollow> MSDN ,存储cookie名称的FormsAuthentication.FormsCookieName属性是只读属性。此属性必须从web.config中读取。
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.
每个实例都需要在web.config一个独立的名字。我建议,包括在现有的变更管理系统身份验证cookie的名称。
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.
这篇关于如何改变FormsCookieName在ASP.NET运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!