0

I have a method GetIP() which takes the System.Web.HttpRequestBase as a parameter. Could anyone help on how do I get the HttpRequestBase object.

I assume it's really basic but not able to figure out.

Thank you.

Renu R
  • 69
  • 2
  • 12

1 Answers1

2

I dont know what context you are in but you can get it from HttpContext.Current.Request. Note that HttpContext.Current does not work if you are hosting the web api outside of iis.

var request = new HttpRequestWrapper(HttpContext.Current.Request);
peco
  • 3,890
  • 1
  • 20
  • 27