如何使用JWT for asp.net Core

时间:2017-04-29 15:20:06

标签: c# asp.net asp.net-web-api asp.net-core jwt

我按照JWT Authentication for Asp.Net Web Api回答将JWT添加到我的asp.net核心项目中但是.net核心不支持System.Web.Http.Filters

保护Web API的任何更好的解决方案???

1 个答案:

答案 0 :(得分:2)

ASP.NET Core MVC支持过滤器。您可以在toDF命名空间中找到它们。例如,查看this guide

请记住,您不需要自己实施JWT身份验证过滤器。这已作为Microsoft.AspNetCore.Mvc.Filters NuGet包的一部分实现。您只需在Microsoft.AspNetCore.Authentication.JwtBearer方法中添加app.UseJwtBearerAuthentication(new JwtBearerOptions { /* options */ })即可在应用中使用JwtBearerAuthentication中间件。