【问题标题】:How can I Set "cookieName" attribute of the "sessionState" XML element in my web.config programatically如何以编程方式在我的 web.config 中设置“sessionState”XML 元素的“cookieName”属性
【发布时间】:2014-08-20 23:14:02
【问题描述】:

目前多个应用程序共享同一个会话 cookie,我不希望出现这种情况,但是,我想在代码中设置值而不是使用 web.config 硬编码值。

有人知道怎么做吗?

【问题讨论】:

    标签: .net asp.net session session-state


    【解决方案1】:

    您可以将应用程序特定的配置文件放在每个应用程序文件夹中,然后在 web.config 中像这样引用它们:

    <authentication configSource="auth.config"></authentication>
    

    在每个 auth.config 中,你可以做你需要的:

    <?xml version="1.0"?>
    <authentication mode="Forms">
        <forms loginUrl="app1_login.aspx" timeout="60" name=".APP1" path="/app1" />
    </authentication>
    

    【讨论】:

      【解决方案2】:

      这是你得到它的方式: How to programmatically get session cookie name? 但你当然也可以设置它..

      【讨论】:

        猜你喜欢
        • 2019-06-23
        • 1970-01-01
        • 2016-09-25
        • 2021-06-22
        • 2023-01-03
        • 2019-03-27
        • 2010-11-15
        • 2010-12-07
        • 2021-05-20
        相关资源
        最近更新 更多