[英]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 asp.net methods into your asp-classic . 代码错误的原因是因为您将asp.net方法混入了asp-classic中 。 To fix this use the suggestion @Jf has suggested in their comment; 要解决此问题,请使用@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.