简体   繁体   English

ASP网页中的用户名

[英]Username in ASP Web page

I have tried searching here on how to get the username in ASP but it always return a 500 error code: 我尝试在此处搜索如何在ASP中获取用户名,但它始终返回500错误代码:

<%
Response.Write("User: " & HttpContext.Current.User.Identity.Name ) 'User.Identity.Name )
%>

Its running on IIS 8.5 windows server 2012 它运行在IIS 8.5 Windows Server 2012上

Do I need to import a class to get access to the username? 我是否需要导入一个类来访问用户名?

To answer your question, No . 要回答您的问题,

The reason your code errors is because you are mixing methods into your . 代码错误的原因是因为您将方法混入了 To fix this use the suggestion @Jf has suggested in their comment; 要解决此问题,请使用@Jf在其评论中提出的建议。

Suggested by @jf @jf 建议

 <% 'As has been pointed out Call is optional use or don't it's your choice. Call Response.Write("User: " & Request.ServerVariables("LOGON_USER")) %> 

IMPORTANT: If you are using "Anonymous Authentication" to access this page the Request.ServerVariables("LOGON_USER") will be empty, it is only populated for other authentication methods (such as "Windows Authentication" ). 重要说明:如果使用“匿名身份验证”访问此页面,则Request.ServerVariables("LOGON_USER")将为空,仅填充其他身份验证方法(例如“ Windows身份验证” )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Django 网页获取 Windows 用户名 - How to get the windows username with Django web page ASP.NET网页Phamton加载 - ASP.NET web page phamton loading 获取Windows用户名,而不是以ASP .NET Web窗体4.5登录用户名 - getting windows username instead of logged in user name in asp .net web form 4.5 如何使用web.config文件301将ASP页面重定向到另一个域 - How to 301 redirect asp page to another domain using web.config file C#中的ASP.Net网页,需要Facebook LIKE&Comment按钮 - ASP.Net Web page in C# , Facebook LIKE & Comment button needed 计划Windows任务以使用用户名和passowrd打开页面 - Schedule Windows Task to open a page with username and passowrd 在公共ASP.NET网站上获取Windows用户名 - Get Windows username on public ASP.NET website 在Windows上从Web浏览器登录没有用户名和密码 - Login without username and password from the web browser on Windows 在Web应用程序中读取Win7当前登录的用户名 - Reading Win7 current logged username in web application 有时,单击指向ASP.NET Web应用程序的电子邮件中的超链接会在第一个事件发生13秒后导致意外的“重影” Page_Load()事件 - sometimes click of hyperlink in email to ASP.NET web app results in unexpected 'ghost' Page_Load() event 13 seconds after first event
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM