随笔分类 - ASP.NET Core
摘要:实体模型 public class BaseModel { public int Id { get; set;} } public class Authorization : BaseModel { public string Route { get; set; } public string Au
阅读全文
摘要:Program.cs #region 授权 builder.Services.AddAuthorization(option => { //添加自定义授权策略 option.AddPolicy("MyPolicy",p => p.RequireClaim(ClaimTypes.NameIdentif
阅读全文
摘要:TokenAuthenticationHandler.cs 首先自定义一个类TokenAuthenticationHandler,然后需要继承IAuthenticationHandler接口 具体代码: public class TokenAuthenticationHandler : IAuthe
阅读全文
摘要:鉴权(Authentication)授权(Authorization) 简单的理解:鉴权衡量你能不能进一道门,授权是你进门了可以干什么 Cookie 1.HTTP无连接无状态,Cookie和Session就是解决此问题。 2.客户端向服务器端发送一个请求的时,服务端向客户端发送一个Cookie 然后
阅读全文
摘要:方法一 app.UseExceptionHandler(configure =>{ configure.Run(async context => { var excHandler = context.Features.Get<IExceptionHandlerPathFeature>(); var
阅读全文