How to get Client Device information in ASP.NET / C#?
问题 I am trying to get the client machine information for access log. How to get Client Device name and Ip address in ASP.NET / C#? 回答1: You can get the direct client IP from the Request.UserHostAddress property: public ActionResult Index() { string ip = Request.UserHostAddress; ... } This being said, there are many situations where this might not be good enough. Suppose for example that your web server is behind a reverse proxy such as nginx or HAProxy. In this case the UserHostAddress will