帮助 - Page.User.Identity 在使用时给出 null("") 值 - IIS 7 和 C# 4.0
我的 Web 应用程序在 iis 7 和 C# 4.0 中运行,我的用户身份为 null,我需要获取 Windows 用户名和密码。我需要做什么?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保站点在 web.config 中设置为需要 Windows 身份验证。初学者请参见此处:
http://msdn.microsoft.com/en-us/ library/532aee0e.aspx
然后确保您正在处理的页面位于需要经过身份验证的访问者的文件夹中(再次是 web.config)
http://msdn.microsoft.com/en-us/library/wce3kxhd.aspx
当您说需要“获取 Windows 用户名和密码”时这是否意味着您想在代码中检索这些内容。您将无法获取密码 - Windows 不会将其提供给 asp.net。
Make sure the site set up to require windows authentication in web.config. See here for starters:
http://msdn.microsoft.com/en-us/library/532aee0e.aspx
Then make sure the page you are working on is in a folder that requires authenticated visitors (again web.config)
http://msdn.microsoft.com/en-us/library/wce3kxhd.aspx
When you say you need to 'get the windows username and password' does that mean you want to retrieve these in your code. You will not be able to get the password - Windows won't provide that to asp.net.