我按照JWT Authentication for Asp.Net Web Api回答将JWT添加到我的asp.net核心项目中但是.net核心不支持System.Web.Http.Filters
保护Web API的任何更好的解决方案???
答案 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中间件。