我有一個登錄頁面,工作正常。我希望得到您的幫助,我該如何註銷。我向您發送我創建的CustomerLogin.cs類。我擁有的login1是對我的web服務的調用。任何人都可以告訴我該怎麼辦?在asp.net登錄註銷
public partial class CustomerLogin : System.Web.UI.Page
{
protected login1.login CustomerLog;
public CustomerLogin()
{
Page.Init += new System.EventHandler(Page_Init);
}
private void Page_Load(object sender, System.EventArgs e)
{
if (Session["userId"] != null)
{
Server.Transfer("FirstPage.aspx");
}
}
private void Page_Init(object sender, EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
}
#region Web Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.submitCusLogin.Click += new System.EventHandler(this.submitCusLogin_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void submitCusLogin_Click(object sender, System.EventArgs e)
{
string customerEmail;
string customerPassword;
customerEmail = txtEmail.Text;
customerPassword = txtPassword.Text;
//Make a call to the Web Service Login
CustomerLog = new login1.login();
//Access the Web method Customer_Details
string getId = CustomerLog.Customer_Details(customerEmail, customerPassword);
//Return a value.Check the value of the variable resultId and
//either grant the customer access or return an error message.
if (getId == "-1")
{
loginLabel.Text = "Invalid Login please re-enter your password and email!";
}
else
{
loginLabel.Text = "Welcome";
Session["userId"] = int.Parse(getId);
Server.Transfer((string)Session["return2Page"]);
}
}
}
我不知道爲什麼人們不使用ASP.NET內置的登錄控件 – Maysam
@Maysam,http://stackoverflow.com/a/6195965/368472 – Pratik