javascript - Retrieve Username after IIS Authentication
问题描述
I have a basic site (HTML/JavaScript) which is using IIS authentication (Windows Authentication) to restrict access. IIS authentication setup
After a user logs on to the site I need to then display their userID.
How can I retrieve the logged in userID knowing the site being restricted is simply HTML and JavaScript.
解决方案
你可以使用这个:
<script language="javascript">
var username = '<%HttpContext.Current.User.Identity.Name %>';
</script>
另一个帖子里有和你类似的问题,你可以参考答案
推荐阅读
- vivado - 将 axi timer 连接到 vivado 中的 microBlaze
- dictionary - 在 Swift 4 中使用 JSONEncoder 将 [String: Encodable] 字典编码为 JSON
- javascript - 未定义的返回函数nodejs
- node.js - 运行 DescribeAccountStatus 的 AWS Lambda 函数不在 NodeJS 中执行
- api - 在多个应用程序中使用单点登录令牌
- java - 为什么 +e 取消而 -e 不取消?
- asp.net-mvc - 对前端而不是后端应用 DataAnnotation 验证
- sqlite - 打开与 sqlite 数据库的连接会导致文件无法被删除
- angular - 选项未显示在primeng下拉列表中?
- ruby - 使用 page.find 时 Site_Prism 未找到 POM 元素