- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的应用程序的 Asp.Net Identity Auth 中间件设置中,我有
app.UseCookieAuthentication(new CookieAuthenticationOptions {
LoginPath = new PathString("/Login/"),
//AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
Provider = new CookieAuthenticationProvider {
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<MyUserManager, MyUser>(
TimeSpan.FromMinutes(30),
(manager, user) => manager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie)
),
},
});
AuthenticationType
行,登录成功(我在我的记录器中收到一条从 Controller 写入的成功消息)但总是重定向回登录屏幕。
The AuthenticationType in the options corresponds to the IIdentity AuthenticationType property. A different value may be assigned in order to use the same authentication middleware type more than once in a pipeline.(Inherited from AuthenticationOptions.)
最佳答案
这是一个字符串,可以是任何东西。但这是身份验证类型的标识符。并且您可以有多种身份验证类型:您的用户数据库、Google、Facebook 等。据我所知,这是在登录时添加为生成的 cookie 的声明。
当您注销用户时,您需要知道身份验证提供程序。如果您的身份验证中间件是这样定义的:
app.UseCookieAuthentication(new CookieAuthenticationOptions {
LoginPath = new PathString("/Login/"),
AuthenticationType = "My-Magical-Authentication",
// etc...
},
});
AuthenticationManager.SignOut("My-Magical-Authentication")
ClaimsIdentity
创建主体时。没有
AuthenticationType
主体无法通过身份验证
because :
/// <summary>
/// Gets a value that indicates whether the identity has been authenticated.
/// </summary>
///
/// <returns>
/// true if the identity has been authenticated; otherwise, false.
/// </returns>
public virtual bool IsAuthenticated
{
get
{
return !string.IsNullOrEmpty(this.m_authenticationType);
}
}
IsAuthenticated
在整个 MVC 代码库中使用,所有身份验证机制都依赖于此。
CookieName
在您的中间件配置中,然后
Options.CookieName = CookieAuthenticationDefaults.CookiePrefix + Options.AuthenticationType;
(
see second if statement in constructor )。
关于asp.net - CookieAuthenticationOptions.AuthenticationType 用于什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35653428/
我有以下代码: public void ConfigureAuth(IAppBuilder app) { app.UseCookieAuthentication(new
在我的应用程序的 Asp.Net Identity Auth 中间件设置中,我有 app.UseCookieAuthentication(new CookieAuthenticationOptions
我的 MVC 6 ASP.NET 5 项目中有以下设置: 配置方法中的Startup.cs: app.UseCookieAuthentication(options => { options.
我正在使用 1.0.1 版本的 asp.net core 并且在我的表单中使用身份验证。 我使用 UseCookieAuthentication 并给出错误 Cannot convert lambda
在 HttpContext.SignInAsync 和 Microsoft.AspNetCore.Authentication.Cookies 中传递给 Microsoft.AspNetCore.Au
我正在使用 OWIN 中间件进行 cookie 身份验证和 openIdConnect。在我将 openIdConnect 身份验证添加到我的启动身份验证代码和 cookie 身份验证选项之前,Log
在 ASP.NET Core 2.1 中,谁能解释一下 CookieAuthenticationOptions.LogoutPath 的作用?每the documentation它说: If the
我在 .NET MVC 4.5 设置中使用 OWIN 的 cookie 身份验证。我在 Startup.Auth.cs (下面的代码)中设置了 cookie 身份验证配置,并且我想访问我在 Contr
我是一名优秀的程序员,十分优秀!