使用Owin Cookie Authentication Muiddrware时,您可以通过更改属性中的AuthenticationType
来部分控制cookie的名称,F.E。:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Test",
//...
});
上面将导致一个名为 .aspnet.test 的cookie。是否有任何方法可以摆脱该 .aspnet。 您需要设置 确定用于持续身份的cookie名称。默认值为" .aspnet.cookies"。如果您更改AuthentiationType的名称,则应更改此值,尤其是如果您的系统多次使用Cookie Authentication Middleware。 如果未在 cookiename 属性中设置自定义cookie名称,则它是基于 authentication typer in authentication> airtentication typer property in noctally of 属性。和硬编码的前缀CookieName
属性。文档说:app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Test",
CookieName = "YourNameGoesHere",
//...
});
".AspNet."
if (string.IsNullOrEmpty(Options.CookieName))
{
Options.CookieName = ".AspNet." + Options.AuthenticationType;
}