How to retrieve PC name of client from C# webservice

我的梦境 提交于 2020-01-03 02:46:08

问题


I have a C# web service running on a separate server machine. I would like to be able to retrieve the client machine name when using a specific method on the web service. I have searched online and people have mentioned that this would be difficult to retrieve client machine names if the clients were connected to a router.

Update: If there is no way to get around the router issue, how would I be able to get the client's information (e.i. ip address, machine name, .... anything)


回答1:


HttpContext.Current.Request.UserHostAddress
HttpContext.Current.Request.UserHostName



回答2:


I don't think this is really possible. If the user is behind a router all you're going to get is whatever the router reports.




回答3:


I don't know of a way to retrieve the client PC name from the web service. However, you could send the name as a parameter to your web service. We send the value of Environment.MachineName as a parameter to one of our web services. This will make the information available on in the web service.

Of course, we only have our WinForms client accessing the web service. You may not be able to do the same thing.



来源:https://stackoverflow.com/questions/492952/how-to-retrieve-pc-name-of-client-from-c-sharp-webservice

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!