Here is code snippet which can help to get IP Address from the request using C#:
public string GetCurrentIpAddress(HttpContextBase httpContext)
{
if (httpContext != null && httpContext.Request != null&& httpContext.Request.UserHostAddress != null)
return httpContext.Request.UserHostAddress;
else
return string.Empty;}
All you have to do is call this function:
string UserIp = GetCurrentIpAddress(Request.RequestContext.HttpContext);
Here is how you can get IP Address of request using C#.
Thanks for dropping by !! Feel free to comment to this post or you can also drop me an email at [email protected]