使用窗体身份验证模式在IIS6.0中部署asp.net应用程序 [英] Deploying asp.net application in IIS6.0 with Forms authentication mode

查看:96
本文介绍了使用窗体身份验证模式在IIS6.0中部署asp.net应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用以下代码获取用户名:
txtName.Text = Environment.UserName;
我已经在IIS中部署了代码,并且在运行应用程序时得到了
用户名在文本框中为"NETWORK SERVICE",而不是登录的用户名.
我正在使用FORMS身份验证模式. (这是强制性的)
预先感谢.

Hi,
I am getting user name by using the following code:
txtName.Text = Environment.UserName;
I have deployed the code in IIS and while running the application then i am getting
user name as "NETWORK SERVICE" in the textbox instead of logged user name.
And I am using the FORMS authentication mode. (this is mandatory)
Thanks in advance.

推荐答案

FormsAuthenticationModule类检测表单身份验证cookie并验证用户身份.成功通过身份验证之后,FormsAuthenticationModule类将使用有关已认证用户的信息来填充当前的User属性(该属性由HttpContext对象公开).

ASP.NET中的表单身份验证 [
The FormsAuthenticationModule class detects the forms authentication cookie and authenticates the user. After successful authentication, the FormsAuthenticationModule class populates the current User property, which is exposed by the HttpContext object, with information about the authenticated user.

Forms Authentication in ASP.NET[^]

HttpContext.Current.User.Identity.Name gives the user name after successful authentication.


这篇关于使用窗体身份验证模式在IIS6.0中部署asp.net应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆