Get request origin in C# api controller

后端 未结 2 1606
不知归路
不知归路 2021-02-07 04:00

Is there a way how can I can get request origin value in the api controller when I\'m calling some api endpoint with ajax call?

For example I\'m making this call from w

2条回答
  •  没有蜡笔的小新
    2021-02-07 04:16

    You can grab it from the API methods via current HTTP request headers collection:

      IEnumerable originValues;
      Request.Headers.TryGetValue("Origin", out originValues)
    

提交回复
热议问题