📄 login.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using infoWeb.WebModules.Accounts.Business;
namespace infoWeb.ThePhile.WebModules.Accounts.Web
{
/// <summary>
/// Summary description for Login.
/// </summary>
public class Login : infoWeb.ThePhile.Web.PhilePage
{
protected System.Web.UI.WebControls.TextBox EmailAddress;
protected System.Web.UI.WebControls.TextBox Password;
protected System.Web.UI.WebControls.Button Submit;
protected System.Web.UI.WebControls.RequiredFieldValidator EmailValidator;
protected System.Web.UI.WebControls.ValidationSummary ValidatorSummary;
protected System.Web.UI.WebControls.Label LoginResult;
protected System.Web.UI.WebControls.Label AuthRedirectFailure;
protected infoWeb.ThePhile.Web.Controls.Server.Navigator MenuNav;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if ((Request["ShowError"] == "true") || (Request["ShowError"] == "1"))
{
AuthRedirectFailure.Text = "You did not have sufficient permission to view the previous page. Please login below.";
AuthRedirectFailure.Visible = true;
}
else
{
AuthRedirectFailure.Visible = false;
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
base.OnInit(e);
InitializeComponent();
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Submit.Click += new System.EventHandler(this.Submit_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Submit_Click(object sender, System.EventArgs e)
{
SitePrincipal newUser = SitePrincipal.ValidateLogin( EmailAddress.Text, Password.Text );
if (newUser == null)
{
LoginResult.Text = "Login failed for " + EmailAddress.Text;
LoginResult.Visible = true;
}
else
{
Context.User = newUser;
FormsAuthentication.SetAuthCookie( EmailAddress.Text, true );
Response.Redirect("/ThePhile/Forums/default.aspx");
}
}
private void Register_Click(object sender, System.EventArgs e)
{
Response.Redirect("new.aspx");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -