c#api身份验证和授权

c#api身份验证和授权

2023年6月20日发(作者:)

c#api⾝份验证和授权

授权

1. 全局 (new AuthorizeAttribute());

2.控制器级别

  [Authorize]

  public class HelloController : ApiController { public string GetTest() { return "hello,world"; } }

3.⽅法级别 public class HelloController : ApiController { [Authorize] public string GetTest() { return "hello,world"; } }

访问⽹址会得到401的状态

如果想要在禁⽌全部的情况下,开放某个⽅法 [Authorize] public class HelloController : ApiController { [AllowAnonymous] public string GetTest() { return "hello,world1"; } public string PostTest() { return "hello,world2"; } }

⾝份验证1.基本⾝份验证

⾝份验证

s⾝份验证

发布者:admin,转转请注明出处:http://www.yc00.com/web/1687249961a31.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信