将应用程序上载到IIS后获取系统用户名 [英] get system username after uploading application to IIS

查看:75
本文介绍了将应用程序上载到IIS后获取系统用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

当我在mysystem/localhost上运行我的应用程序时,它为我提供了正确的用户名.但是,当我在IIS上托管我的应用程序,然后在其他用户的PC上打开应用程序时,它应该显示该PC的用户名.但事实并非如此.

如何检索该PC的用户名?

我已经尝试过下面的代码行来获取用户名.

Hi all,

When i run my application on mysystem/localhost it gives me correct username. but when i host my application on IIS and then open application on other user''s pc then it should show that pc''s username. but it doesn''t.

how to retrieve username of that pc?

I have tried below lines of code to get the username.

if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
{
     string userName = "Hello, " + System.Web.HttpContext.Current.User.Identity.Name;
}

string ddd = System.Net.Dns.GetHostName();

string s = Page.User.Identity.Name;

string sss= System.Environment.UserName;

string test= HttpContext.Current.Request.LogonUserIdentity.ToString();



还有其他解决方案来获取用户名吗?

感谢



are there any other solutions to get the username?

thanks

推荐答案

您需要研究Web应用程序的工作方式以及客户端服务器的基础知识.

您编写的服务器代码在服务器上执行,仅将响应发送给用户.并且由于您的代码正在服务器上执行,因此它将获得服务器的计算机详细信息(mysystem/localhost),而不是正在浏览它的用户的计算机详细信息.

更糟糕的是,您尚未发布代码.

询问我是否需要其他详细信息...
You need to study how a web application works and the client server basics.

The server code you have written executes on the server and only sends the response to the user. And since your code is executing on the server, it will get the machine details ( mysystem/localhost) of the server and NOT of the user who is browsing it.

To make the matter worse, you have not posted the code.

Ask me if you need any other details...


这篇关于将应用程序上载到IIS后获取系统用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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