Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 GetIP() 方法,它将 System.Web.HttpRequestBase 作为参数。任何人都可以帮助我如何获取 HttpRequestBase 对象。
我认为这真的很基本,但无法弄清楚。
谢谢你。
我不知道你在什么背景下,但你可以从中得到它HttpContext.Current.Request。请注意,HttpContext.Current如果您在 iis 之外托管 web api,这将不起作用。
HttpContext.Current.Request
HttpContext.Current
var request = new HttpRequestWrapper(HttpContext.Current.Request);