【发布时间】:2018-03-23 12:14:05
【问题描述】:
在我们的应用程序中,我们以两种不同的方式对用户进行身份验证,并且它可以正常工作。现在我想知道当用户尝试通过控制器操作访问页面并且用户已登录时使用哪个 AuthenticationType。这可能吗?
// Startup.auth.cs
public void ConfigureAuth(IAppBuilder app)
{
app.UseWsFederationAuthentication(...
app.UseOpenIdConnectAuthentication(...
// Controller
[AllowAnonymous]
public ActionResult Activation()
{
if (!this.Request.IsAuthenticated)
{
// sign in using WsFederation, works
}
else if (/*Signed in with OpenIdConnect AuthType*/)
{
return Redirect("/");
}
return View();
}
这里重要的是 els-if 语句。我可以访问 OwinContext。有没有办法知道它使用了哪个 AuthenticationType?
【问题讨论】:
标签: c# asp.net asp.net-mvc authentication owin