请求。服务器变量——它去哪儿了?(复制)

时间:2022-08-22 01:53:23

This question already has an answer here:

这个问题已经有了答案:

I'm trying to get the data that was in Request.ServerVariables["REMOTE_ADDR"] in an API controller in ASP.Net Web Api. But the servervariables dictionary is gone. Is that property/data still available?

我想要得到所要求的数据。ASP中的API控制器中的服务器变量["REMOTE_ADDR"]。净Web Api。但是servervariables字典已经消失了。该属性/数据是否仍然可用?

1 个解决方案

#1


2  

Request.ServerVariables is there or not on the hosting medium that you have. Simply use Request.Properties["MS_HttpContext"].Request.ServerVariables["REMOTE_ADDR"] to get what you need.

请求。服务器变量是否存在于您所拥有的宿主媒体上。简单地使用Request.Properties .Request“MS_HttpContext”。获取所需的服务器变量["REMOTE_ADDR"]。

#1


2  

Request.ServerVariables is there or not on the hosting medium that you have. Simply use Request.Properties["MS_HttpContext"].Request.ServerVariables["REMOTE_ADDR"] to get what you need.

请求。服务器变量是否存在于您所拥有的宿主媒体上。简单地使用Request.Properties .Request“MS_HttpContext”。获取所需的服务器变量["REMOTE_ADDR"]。