删除cookie名称中的.AspNet前缀

时间:2016-06-24 10:32:47

标签: c# authentication cookies owin

使用OWIN Cookie身份验证中间件时,您可以通过更改属性中的AuthenticationType来部分控制Cookie的名称,例如:

app.UseCookieAuthentication(new CookieAuthenticationOptions
    {
        AuthenticationType = "Test",
        //...
    });

上面会生成一个名为 .AspNet.Test 的cookie。有没有办法摆脱 .AspNet。前缀,因为我们相信它会显示有关我们正在使用的堆栈的有价值的信息。

1 个答案:

答案 0 :(得分:2)

您需要设置CookieName属性。文档说:

  

确定用于保留标识的cookie名称。默认值为“.AspNet.Cookies”。如果更改AuthenticationType的名称,则应更改此值,尤其是在系统多次使用cookie身份验证中间件的情况下。

app.UseCookieAuthentication(new CookieAuthenticationOptions
    {
        AuthenticationType = "Test",
        CookieName = "YourNameGoesHere",
        //...
    });
相关问题