【发布时间】:2016-05-13 01:39:33
【问题描述】:
嗯,这是一个错误。 我决定将我的 MVC5 应用程序迁移到 MVC6 并且一切都很好,直到我需要迁移我的身份验证。 我的 MVC 应用程序使用返回令牌的外部 Web Api 2 应用程序登录。 我构建了一个过滤器来处理这个问题:
/// <summary>
/// Uses the session to authorize a user
/// </summary>
public class SimpleAuthorize : AuthorizeAttribute
{
/// <summary>
/// Authorizes the user
/// </summary>
/// <param name="httpContext">The HTTP Context</param>
/// <returns></returns>
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
var accessToken = httpContext.Session["AccessToken"];
if (accessToken == null)
return false;
return true;
}
}
应用于所有控制器。 现在,您似乎是can't do that anymore as mentioned here。 那么,如何让我的应用程序使用 API?
我尝试过搜索,但没有发现任何可以帮助我解决我的情况。有谁知道我该如何解决这个问题,或者可以为我指出一些像样的文档的方向?
【问题讨论】:
标签: asp.net asp.net-mvc asp.net-core-mvc