[英]Returning logged in user as a string
I am new to C# and not sure if I'm asking this correctly. 我是C#的新手,不确定我是否正确询问了此内容。 I need to return the current logged in user of my app as a string. 我需要以字符串形式返回应用程序的当前登录用户。
System.Web.UI.WebControls.LoginName
I am using the Visual Studio 2010 ASP.NET Web Site template. 我正在使用Visual Studio 2010 ASP.NET网站模板。
Response.Write(System.Web.UI.WebControls.LoginName);
Will not work because it is not of the right "type". 因为它不是正确的“类型”,所以将无法工作。 How do I get this value as text? 如何获得此值作为文本?
System.Web.UI.WebControls.LoginName
is a control. System.Web.UI.WebControls.LoginName
是一个控件。
The data item is Page.User.Identity.Name
数据项为Page.User.Identity.Name
如果只需要用户名,则可以使用HttpContext.Current.User.Identity.Name;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.