简体   繁体   English

ASP.NET中的登录和凭据问题

[英]Logon & credentials issue in ASP.NET

Hi I am using asp.net. 嗨,我正在使用asp.net。 My requirement is as follows 我的要求如下

The user logs in to his/her system using his network credentials. 用户使用其网络凭据登录到他/她的系统。 After successfully logging into the system he opens the home page of the application like www.xyz.com/Index.aspx. 成功登录系统后,他打开应用程序的主页,如www.xyz.com/Index.aspx。 Since he is not authorized he is redirected to www.xyz.com/logon.aspx 由于他未被授权,因此将其重定向到www.xyz.com/logon.aspx

But the crux here is he uses the same user ID & password which he used earlier to log in to the system.Thus he has to login twice. 但问题的关键是他使用与之前登录系统时相同的用户名和密码,因此必须登录两次。 I want that once the user successfully logs into the system he should be able to directly open the www.xyz.com/Index.aspx & not asked to login again 我希望用户成功登录到系统后,他应该能够直接打开www.xyz.com/Index.aspx且不要求再次登录

We are using IIS to host our application. 我们正在使用IIS托管我们的应用程序。 The pages are developed on dot net framework 2.0 & developed using Visual Studio 2005 这些页面在dot net framework 2.0上开发,并使用Visual Studio 2005开发。

  1. Configure IIS to use Windows authentication on the virtual directory, and turn off all the other authentication types. 将IIS配置为在虚拟目录上使用Windows身份验证,然后关闭所有其他身份验证类型。
  2. Remove your login page, you don't need one. 删除您的登录页面,您不需要一个。
  3. Put this in your web.config file in the <system.web> section: 将其放在<system.web>部分的web.config文件中:

     <authentication mode="Windows"/> <authorization> <deny users="?"/> </authorization> 
  4. Use User.Identity to get the user's WindowsIdentity in a web page. 使用User.Identity在网页中获取用户的WindowsIdentity

EDIT: ASP.NET supports three authentication providers out of the box: Forms , Passport and Windows . 编辑: ASP.NET开箱即用地支持三个身份验证提供程序: FormsPassportWindows If you want something else then you'll have to implement it from scratch. 如果您还需要其他东西,则必须从头开始实施。 A quick Google search turned up this Custom Authentication Provider how-to , which might give you some pointers. 快速的Google搜索显示了该“自定义身份验证提供程序”的操作方法 ,这可能会给您一些指示。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM