简体   繁体   English

Web API:获取请求来源

[英]web api: get the request origin

I am testing a web api and I am setting the From header in the request with Postman, like this: 我正在测试Web API,并在与Postman的请求中设置From标头,如下所示: 在此处输入图片说明

But in my controller, when I evaluate this.Request.Headers.From , I'm getting a false result: 但是在我的控制器中,当我评估this.Request.Headers.From ,我得到了一个错误的结果:

在此处输入图片说明

But when I am evaluating only the Request.Headers and I'm scrolling to the ResultView , I see that U have a header with the key From. 但是,当我仅评估Request.Headers并滚动到ResultView ,我看到U具有带有键From的标头。

在此处输入图片说明

So what's the point of the member From from the this.Request.Headers.From ? 那么this.Request.Headers.From成员Fromthis.Request.Headers.From什么?

It looks like the From header is standardized to an email address. 看起来“ From标头已标准化为电子邮件地址。 Likely the .NET code is excluding it since it is not an email address. .NET代码可能不包含它,因为它不是电子邮件地址。

Consider using a different header. 考虑使用其他标头。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM