ASP.NET form authentication ne rabotaet

Обсуждение серверного программирования.

Модераторы: Duncon, Yurich

Ответить
michael
Сообщения: 116
Зарегистрирован: 15 июл 2004, 13:06
Откуда: ISRAEL (ранее - из Литвы)
Контактная информация:

написал следушее
<configuration>


<system.web>
<authentication mode="Forms">
<forms name=".ASPXAUTH" loginUrl="LoginDemo.aspx" />
</authentication>
</system.web>



<appSettings>
<add key="dbConn.ConnectionString" value="workstation id=OLD;packet size=4096;integrated security=SSPI;data source="(local)";persist security info=False;initial catalog=Trinity" />
</appSettings>


<location path="SecurePageDemo1.aspx">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>

<location path="SecurePageDemo2.aspx">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
</configuration>




на SecurePageDemo1.aspx написал
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
lblAuthUser.Text = User.Identity.Name;
lblAuthType.Text = User.Identity.AuthenticationType;
}



на LoginDemo.aspx написал
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Web.Security;
using System.Configuration;
namespace Mod16CS
{
/// <summary>
/// Summary description for LoginDemo.
/// </summary>
public class LoginDemo : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox txtUserName;
protected System.Web.UI.WebControls.TextBox txtPassword;
protected System.Web.UI.WebControls.Button cmdLogin;
protected System.Web.UI.WebControls.Label lblInfo;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.cmdLogin.Click += new System.EventHandler(this.cmdLogin_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion


private void cmdLogin_Click(object sender, System.EventArgs e)
{
string strCustomerID="";

if (strCustomerID == "")
{
//Redirect browser back to originating page
//and generate a non-persistant authentication cookie containing
//the strCustomerID
FormsAuthentication.RedirectFromLoginPage(strCustomerID, false);
}
else
{
//Otherwise display an error message
lblInfo.Text = "Login Failed!";
}
}
}
}



но почему то заходит свободно на SecurePageDemo1.aspx . Может надо IIS настроить по особеному, если да-подскажите пожалуйста
Ответить