温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:文件在线管理系统0.30源码
当前文件:
FileManager/Web.Processor/Manage/LoginProcessor.cs,打开代码结构图
FileManager/Web.Processor/Manage/LoginProcessor.cs,打开代码结构图1using System; 2
using System.Web; 3
using System.Web.Security; 4
using System.Web.SessionState; 5
6
namespace ptw.FileManager.Web.Processor.Manage 7
{ 8
/// <summary> 9
/// 登录处理 10
/// </summary> 11
public class LoginProcessor 12
{ 13
private string _Value; 14
private bool _LoginState = true; 15
16
/// <summary> 17
/// 处理结果 18
/// </summary> 19
public string Value 20
{ 21
get { return _Value; } 22
} 23
24
/// <summary> 25
/// 登录验证是否成功 26
/// </summary> 27
public bool LoginState 28
{ 29
get { return _LoginState; } 30
} 31
32
/// <summary> 33
/// 构造方法 34
/// </summary> 35
public LoginProcessor() 36
{ 37
HttpRequest Request = HttpContext.Current.Request; 38
HttpSessionState Session = HttpContext.Current.Session; 39
40
string userName = Request.Form["username"]; 41
string passWord = Request.Form["password"]; 42
string code = Request.Form["code"]; 43
44
if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(passWord) || string.IsNullOrEmpty(code)) 45
{ 46
this._Value = "请填写完整"; 47
this._LoginState = false; 48
} 49
else if (Session["CheckCode"] == null) 50
{ 51
this._Value = "验证码已过期"; 52
this._LoginState = false; 53
} 54
else if (code != Session["CheckCode"].ToString()) 55
{ 56
this._Value = "验证码错误"; 57
this._LoginState = false; 58
} 59
60
if (this._LoginState == true) 61
{ 62
if (FormsAuthentication.Authenticate(userName, passWord)) 63
{ 64
FormsAuthentication.SetAuthCookie(userName, false); 65
} 66
else 67
{ 68
this._Value = "身份验证失败"; 69
} 70
} 71
} 72
} 73
}





}