采用JWT实现WebAPI认证

JWT WebAPI(.NetFramework 4.5框架)

Author:TJ Date:2020.11.18

创建Asp.net web app项目 create_img

选择.net framework 4.5 type_img

Web api webapi_img

Nuget Cors 跨域 nuget_img 接受 accept_img

Jwt jwt_img

确定 preview_img

添加TokenManager.cs类

添加控制器Controller controller_img

路由route route_img

运行run run_img

http://localhost:60304/account/validLogin?username=tj&userpassword=1234 http://localhost:60304/account/validLogin?username=tj&userpassword=tj

error_img

key_img

再次运行 token_img

view token_img

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6InRqIiwibmJmIjoxNjA1ODAyNzA0LCJleHAiOjE2MDU4MDYzMDMsImlhdCI6MTYwNTgwMjcwNH0.RrTrbiGCscjAR0iQUdMlFrlGAO7ZnwrZiy_VuJXoxkw

post_img

post2_img

https://jwt.io

jwt_io

add filter add filter

Postman 无Header no header

错误header header err

正确header correct header

结束。

Copyright © 德和居 2021 粤ICP备20069867号 在CC-BY-NC-SA 4.0协议下授权使用,除非另有说明 all right reserved,powered by Gitbook本文修订时间: 2020-12-23 22:17:49

results matching ""

    No results matching ""

    results matching ""

      No results matching ""