<configuration>
<system.web>
<pages buffer ="true" /> <!--在服务器端缓存,一起发送至客户端-->
<customErrors mode ="RemoteOnly" defaultREdirect ="error.aspx" /> <!--网页出错时转向 error.aspx-->
<authentication mode ="Forms">
<forms name ="authWeb" loginUrl ="login.aspx" protection ="ALL"> </forms>
<!--注: <authorization><allow users=" ? " /></authorization>
在代码中调用
if(true)
{
System.WebSecurity.FormsAuthentication.SetAuthCookie(this.TextBox1.Text,true) 永久的 Cookies
System.WebSecurity.FormsAuthentication.RedirectFromLoginPage(this.TextBox1.Text,false) 临时的 Cookies
}
else
{
Response.Write(" 非法的用户! ");
}
System.Web.Security.FormsAuthentication.SignOut(); 清除 Cookies -->
<credentials passwordFormat ="Clear/MD5/SHA1">
<!--MD5 方法,代码: Response.Write(System.Web.Security.FormsAuthentication.HashPasswordFroStoringinConfigFile(this.Name.Text,"MD5"))-->
<user name ="aaa" password ="aaa" />
<!--允许用户登陆,在代码中调用:
if(System.Web.Security.FormsAuthentication.Authenticate(this.name.Text,this.Pwd.Text))
{
System.WebSecurity.FormsAuthentication.RedirectFromLoginPage(this.TextBox1.Text,false) 临时的 Cookies
} -->
</credentials >
</authentication>
<pages validateRequest="false" /> <!--防止客户端传html标签报错-->
</system.web>
<appSettings>
<add key ="strConn" value ="server=.;database=Login;uid=sa;pwd=sa" />
<!--在代码中调用 SqlConnection conn = new SqlConnection (System.Configuration.ConfigurationSettings.AppSettings[strConn])-->
</appSettings>
</configuration>
<system.web>
<pages buffer ="true" /> <!--在服务器端缓存,一起发送至客户端-->
<customErrors mode ="RemoteOnly" defaultREdirect ="error.aspx" /> <!--网页出错时转向 error.aspx-->
<authentication mode ="Forms">
<forms name ="authWeb" loginUrl ="login.aspx" protection ="ALL"> </forms>
<!--注: <authorization><allow users=" ? " /></authorization>
在代码中调用
if(true)
{
System.WebSecurity.FormsAuthentication.SetAuthCookie(this.TextBox1.Text,true) 永久的 Cookies
System.WebSecurity.FormsAuthentication.RedirectFromLoginPage(this.TextBox1.Text,false) 临时的 Cookies
}
else
{
Response.Write(" 非法的用户! ");
}
System.Web.Security.FormsAuthentication.SignOut(); 清除 Cookies -->
<credentials passwordFormat ="Clear/MD5/SHA1">
<!--MD5 方法,代码: Response.Write(System.Web.Security.FormsAuthentication.HashPasswordFroStoringinConfigFile(this.Name.Text,"MD5"))-->
<user name ="aaa" password ="aaa" />
<!--允许用户登陆,在代码中调用:
if(System.Web.Security.FormsAuthentication.Authenticate(this.name.Text,this.Pwd.Text))
{
System.WebSecurity.FormsAuthentication.RedirectFromLoginPage(this.TextBox1.Text,false) 临时的 Cookies
} -->
</credentials >
</authentication>
<pages validateRequest="false" /> <!--防止客户端传html标签报错-->
</system.web>
<appSettings>
<add key ="strConn" value ="server=.;database=Login;uid=sa;pwd=sa" />
<!--在代码中调用 SqlConnection conn = new SqlConnection (System.Configuration.ConfigurationSettings.AppSettings[strConn])-->
</appSettings>
</configuration>