取得指定Header:
[HttpGet, Route("/GetHeader")]
public string GetHeader()
{
if (Request.Headers.TryGetValue("token", out var token))
{
return token;
}
return "not find token";
}
測試:
輸出:
Header=[Connection, keep-alive]
Header=[Accept, */*]
Header=[Accept-Encoding, gzip, deflate, br]
Header=[Host, localhost:5001]
Header=[User-Agent, PostmanRuntime/7.28.3]
Header=[token, testToken]
Header=[Postman-Token, 03bcf4c8-36f5-4e67-a061-037c1590010f]
留言
張貼留言
如果有任何問題、建議、想說的話或文章題目推薦,都歡迎留言或來信: a@ruyut.com