This question already has an answer here:
这个问题已经有了答案:
- ASP.NET Web API: How do you read server variables in a Web API controller? 3 answers
- ASP。NET Web API:如何在Web API控制器中读取服务器变量?3答案
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"]。