- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我将 asp.net MVC 5.2 与 asp.net 身份版本 2.2.1 和 Entity Framework 6.1.3 一起使用。在某些时候,在 Controller 中,我需要知道当前正在使用的 AuthenticationProperties 的内容,更具体地说,我需要知道 isPersistent 的值。
最佳答案
您可以通过调用 AuthenticateAsync()
通过 AspNet.Identity
访问当前 session 的 AuthenticationProperties
内容。此处的表单例份验证不相关,因为 session 属于 Identity
。
要获取整个 AuthenticationProperties
对象:
@using Microsoft.AspNet.Identity;
@using System.Threading.Tasks;
public async Task<ActionResult> SomeMethodName(...) {
{
var authenticateResult = await HttpContext.GetOwinContext()
.Authentication.AuthenticateAsync(
DefaultAuthenticationTypes.ApplicationCookie
);
一个你有authenticateResult
,提取属性值的语法(在你的例子中是IsPersistent
)是:
var isPersistent = authenticateResult.Properties.IsPersistent; //// true or false
关于c# - 如何获取isPersistent(AuthenticationProperties),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38563807/
我正在努力了解 FormsAuthenticationTicket 类中的 isPersistent 属性的用途。 http://msdn.microsoft.com/en-us/library/ky
我好像不太明白OWIN cookie认证中的IsPersistent是如何工作的,下面的代码是使用IsPersistent: var context = Request.GetOwinContext(
在 SQL Server 中,我们如何使用 T-SQL 关闭计算列的 PERSISTED 属性?我可以使用 Management Studio GUI 执行此操作,但不知道如何使用 T-SQL 执行此
我有一个 asp.net MVC/angular 应用程序(不是 .net core)使用 OpenIdConnect 对我们的 IdentityServer4 服务器进行身份验证。身份服务器上的登录
我有一个 ASP.NET MVC 5应用程序使用 ASP.NET Identity 2.1.0用于用户身份验证。 过去一切正常,但现在我发现持久化用户 session 不再起作用了。我不知道是什么改变
我有一个使用 ASP.NET Identity 的 ASP.NET MVC 5.0 项目。当用户登录时,我使用此功能通过系统跟踪用户。 SignInManager.SignIn(user,IsPers
我知道这个问题似乎已经有人问过了,但这与 ASP.NET Core 而不是 ASP.NET 5 有关。 当用户关闭浏览器选项卡时,我试图让用户注销;我正在 MacOS 上使用 Chrome 和 Saf
我将 WIF 与 WS Federation 结合使用,以便我的 ASP.NET 应用程序可以针对 STS (Thinktecture IdentityServer) 进行身份验证。在我的 RP 中,
使用ASPNETCORE OpenId身份验证中间件和Cookie中间件。我总是看到来自 OpenId 身份验证的 cookie 设置为在 1969 年 12 月 31 日到期(在 Chrome 调试
我是一名优秀的程序员,十分优秀!