我想获取系统的用户名,但是在服务器上不起作用,它只能在本地主机上运行 [英] I want to get user name of the system but is does not work on server it only run in local host

查看:80
本文介绍了我想获取系统的用户名,但是在服务器上不起作用,它只能在本地主机上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

i want to get user name of the system but is does not work on server it only run in local host





我尝试了什么:



i希望得到系统的用户名但是在服务器上不起作用它只能在本地主机



What I have tried:

i want to get user name of the system but is does not work on server it only run in local host

推荐答案

这是因为C#代码是在服务器而不是客户端执行的:因此当您使用C#代码获取主机系统名称时,它会返回服务器名称,而不是客户端。它在本地主机上进行开发时似乎有效,因为这两台计算机是同一台物理机。

您可以尝试 HttpRequest.UserHostName属性(System.Web) [ ^ ]但是很有可能它只会返回IP地址。
That's because C# code is executed at the Server, not the Client: so when you use C# code to get a host system name, it returns the Server name, not the Client. It appears to work when you run it in development on the local host because the two computers are the same physical machine.
You can try HttpRequest.UserHostName Property (System.Web)[^] but there is a good chance it will just return the IP address.


这篇关于我想获取系统的用户名,但是在服务器上不起作用,它只能在本地主机上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆