读书人

asp.net提供的三种认证方式

发布时间: 2012-08-26 16:48:05 作者: rapoo

asp.net提供的3种认证方式

asp.net提供了3种认证方式: windows身份验证, Forms验证和Passport验证.
windows身份验证: IIS根据应用程序的设置执行身份验证.要使用这种验证方式,在IIS中必须禁用匿名访问.
Forms验证:用Cookie来保存用户凭证,并将 未经身份验证的用户重定向到自定义的登录页.
Passport验证:通过Microsoft的集中身份验证服务执行的,他为成员站点提供单独登录 和核心配置文件服务.

一. 配置windows身份验证
1)配置IIS设置
asp.net提供的三种认证方式
2)设置Web.config
<system.web>
<authentication mode = "Windows">
<!--通知操作系统将当前登录的用户的信任书传递给浏览器-->
<authorization>
<!--禁止匿名用户访问-->
<deny users = "?"/>
</authorization>
</system.web>
二.配置Forms身份认证
1)配置web.config

asp.net提供的三种认证方式<?xml version="1.0"?>
asp.net提供的三种认证方式<!--
asp.net提供的三种认证方式 Note: As an alternative to hand editing this file you can use the
asp.net提供的三种认证方式 web admin tool to configure settings for your application. Use
asp.net提供的三种认证方式 the Website->Asp.Net Configuration option in Visual Studio.
asp.net提供的三种认证方式 A full list of settings and comments can be found in
asp.net提供的三种认证方式 machine.config.comments usually located in
asp.net提供的三种认证方式 \Windows\Microsoft.Net\Framework\v2.x\Config
asp.net提供的三种认证方式-->
asp.net提供的三种认证方式<configuration>
asp.net提供的三种认证方式 <appSettings/>
asp.net提供的三种认证方式 <connectionStrings/>
asp.net提供的三种认证方式 <!--允许匿名用户登录register.aspx页-->
asp.net提供的三种认证方式 <location path="register.aspx">
asp.net提供的三种认证方式 <system.web>
asp.net提供的三种认证方式 <authorization>
asp.net提供的三种认证方式 <allow users="?" />
asp.net提供的三种认证方式 </authorization>
asp.net提供的三种认证方式 </system.web>
asp.net提供的三种认证方式 </location>
asp.net提供的三种认证方式 <system.web>
asp.net提供的三种认证方式 <!--
asp.net提供的三种认证方式 Set compilation debug="true" to insert debugging
asp.net提供的三种认证方式 symbols into the compiled page. Because this
asp.net提供的三种认证方式 affects performance, set this value to true only
asp.net提供的三种认证方式 during development.
asp.net提供的三种认证方式 -->
asp.net提供的三种认证方式 <compilation debug="true"/>
asp.net提供的三种认证方式 <!--
asp.net提供的三种认证方式 The <authentication> section enables configuration
asp.net提供的三种认证方式 of the security authentication mode used by
asp.net提供的三种认证方式 ASP.NET to identify an incoming user.
asp.net提供的三种认证方式 -->
asp.net提供的三种认证方式 <authentication mode="Forms">
asp.net提供的三种认证方式 <forms name="auth" loginUrl="login.aspx" timeout="30" protection="All" path="/"></forms>
asp.net提供的三种认证方式 </authentication>
asp.net提供的三种认证方式 <!--禁止匿名用户登录-->
asp.net提供的三种认证方式 <authorization>
asp.net提供的三种认证方式 <deny users="?"/>
asp.net提供的三种认证方式 </authorization>
asp.net提供的三种认证方式 <!--
asp.net提供的三种认证方式 The <customErrors> section enables configuration
asp.net提供的三种认证方式 of what to do if/when an unhandled error occurs
asp.net提供的三种认证方式 during the execution of a request. Specifically,
asp.net提供的三种认证方式 it enables developers to configure html error pages
asp.net提供的三种认证方式 to be displayed in place of a error stack trace.
asp.net提供的三种认证方式
asp.net提供的三种认证方式 <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
asp.net提供的三种认证方式 <error statusCode="403" redirect="NoAccess.htm" />
asp.net提供的三种认证方式 <error statusCode="404" redirect="FileNotFound.htm" />
asp.net提供的三种认证方式 </customErrors>
asp.net提供的三种认证方式 -->
asp.net提供的三种认证方式 </system.web>
asp.net提供的三种认证方式</configuration>
asp.net提供的三种认证方式
asp.net提供的三种认证方式

2)登录页面代码
login.aspx

1asp.net提供的三种认证方式asp.net提供的三种认证方式<%@ Page Language="C#" AutoEventWireup="true" CodeFile="login.aspx.cs" Inherits="login" %>
2asp.net提供的三种认证方式
3asp.net提供的三种认证方式<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4asp.net提供的三种认证方式
5asp.net提供的三种认证方式<html xmlns="http://www.w3.org/1999/xhtml" >
6asp.net提供的三种认证方式<head runat="server">
7asp.net提供的三种认证方式 <title>Untitled Page</title>
8asp.net提供的三种认证方式</head>
9asp.net提供的三种认证方式<body>
10asp.net提供的三种认证方式 <form id="form1" runat="server">
11asp.net提供的三种认证方式 <div>
12asp.net提供的三种认证方式 <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
13asp.net提供的三种认证方式 <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="登陆" /></div>
14asp.net提供的三种认证方式 </form>
15asp.net提供的三种认证方式</body>
16asp.net提供的三种认证方式</html>

1asp.net提供的三种认证方式using System;
2asp.net提供的三种认证方式using System.Data;
3asp.net提供的三种认证方式using System.Configuration;
4asp.net提供的三种认证方式using System.Collections;
5asp.net提供的三种认证方式using System.Web;
6asp.net提供的三种认证方式using System.Web.Security;
7asp.net提供的三种认证方式using System.Web.UI;
8asp.net提供的三种认证方式using System.Web.UI.WebControls;
9asp.net提供的三种认证方式using System.Web.UI.WebControls.WebParts;
10asp.net提供的三种认证方式using System.Web.UI.HtmlControls;
11asp.net提供的三种认证方式
12asp.net提供的三种认证方式public partial class login : System.Web.UI.Page
13asp.net提供的三种认证方式asp.net提供的三种认证方式{
14asp.net提供的三种认证方式 protected void Page_Load(object sender, EventArgs e)
15asp.net提供的三种认证方式asp.net提供的三种认证方式 {
16asp.net提供的三种认证方式
17asp.net提供的三种认证方式 }
18asp.net提供的三种认证方式 protected void Button1_Click(object sender, EventArgs e)
19asp.net提供的三种认证方式asp.net提供的三种认证方式 {
20asp.net提供的三种认证方式 FormsAuthentication.RedirectFromLoginPage(this.TextBox1.Text, false);
21asp.net提供的三种认证方式 }
22asp.net提供的三种认证方式}
23asp.net提供的三种认证方式


三.配置Passport身份认证
需要安装Passport Software Developer Kit.这种认证方式适合于跨站之间的应用,用户只有一个用户名和密码可以访问任何成员站。

IIS 身份验证

如果 ASP.NET 针对 Windows 身份验证进行配置,则 ASP.NET 依靠 IIS,利用配置好的身份验证模式对其客户端进行身份验证。IIS 通过检查特定应用程序的元数据库设置来确定其身份验证模式。成功验证某个用户的身份后,IIS 将代表经过身份验证的用户的 Windows 令牌传递给宿主 ASP.NET 的 ASP.NET 辅助进程 (w3wp.exe)。如果应用程序使用在 IIS 中配置的虚拟目录来支持匿名访问,该令牌代表匿名 Internet 用户帐户;否则,该令牌代表经过身份验证的用户。

IIS 支持以下身份验证模式:

读书人网 >ASP

热点推荐