📄 adminlogin.ascx.cs
字号:
namespace Seaskyer.WebApp.skyNews.Pages.AdminMSC
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Security;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Seaskyer.Strings;
/// <summary>
/// AdminLogin : 后台管理登陆。
/// </summary>
public class AdminLogin : basePage
{
protected TextBox Username, Password, VertifyCode;
protected DropDownList ssUserID;
protected Label label1;
protected System.Web.UI.HtmlControls.HtmlTableRow loginType;
private void Page_Load(object sender, System.EventArgs e)
{
if( !user.CheckValiable(user.userID) ) Response.Redirect(basePath + "Index/Login.aspx");
label1.Visible = false;
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
// 响应登陆事件
protected void Submit_Click(object sender, System.EventArgs e)
{
string userid = Username.Text.Trim();
string userpwd = Password.Text.Trim();
if( !user.CheckValiable(Session["SignCode"]) )
{
label1.Text = "验证码已失效,请刷新重试。"; label1.ForeColor = Color.Red;
label1.Visible = true;
return;
}
else if( !Object.Equals(Session["SignCode"], VertifyCode.Text) )
{
label1.Text = "验证码输入错误"; label1.ForeColor = Color.Red;
label1.Visible = true;
return;
}
// 检测用户名和密码
dp.CommandText = "SELECT UserPwd FROM [ssUser] WHERE UserID = @UserID";
dp.Parameter.Add("UserID", userid);
DataRow dr = dp.ReaderDataRowSQL();
if( dr == null)
{
user.MessageShowBack("用户名输入不正确!");
}
else if(dr[0].ToString() != Function.NoneEncrypt(userpwd, user.EncryptMethod))
{
user.MessageShowBack("密码错误!");
}
else
{
try
{
//string formUrl = FormsAuthentication.GetRedirectUrl(userid, false);
FormsAuthentication.SetAuthCookie(userid, false, "/");
Response.Redirect(basePath + "Admin/Main.aspx");
//FormsAuthentication.RedirectFromLoginPage(userid, true, "");
// if( formUrl == basePath + "default.aspx" )
// Response.Redirect(basePath + "Admin/Main.aspx");
// else
// Response.Redirect(formUrl);
}
catch
{
user.MessageShowBack("未知错误,请重试", Page);
return;
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -