<system.web>
<!--这里设置身份验证信息-->
<authentication mode="Forms">
<forms loginUrl="/Login/Login" timeout="2880" name="LyIng.Net" />
</authentication>
<!--这里设置身份验证信息-->
<authentication mode="Forms">
<forms loginUrl="/Login/Login" timeout="2880" name="LyIng.Net" />
</authentication>
if (CheckLogin.Instance.Login(UserName, PassWord))
{
Users ModelUser = new Users() { ID = 10000, Name = UserName, UserName = UserName, PassWord = PassWord, Roles = "admin" };
string UserData = SerializeHelper.Instance.JsonSerialize<Users>(ModelUser);//序列化用户实体
//保存身份信息
FormsAuthenticationTicket Ticket = new FormsAuthenticationTicket(1, UserName, DateTime.Now, DateTime.Now.AddHours(12), false, UserData);
HttpCookie Cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(Ticket));//加密身份信息,保存至Cookie
Response.Cookies.Add(Cookie);
return Redirect("/Home/Index");
}
{
Users ModelUser = new Users() { ID = 10000, Name = UserName, UserName = UserName, PassWord = PassWord, Roles = "admin" };
string UserData = SerializeHelper.Instance.JsonSerialize<Users>(ModelUser);//序列化用户实体
//保存身份信息
FormsAuthenticationTicket Ticket = new FormsAuthenticationTicket(1, UserName, DateTime.Now, DateTime.Now.AddHours(12), false, UserData);
HttpCookie Cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(Ticket));//加密身份信息,保存至Cookie
Response.Cookies.Add(Cookie);
return Redirect("/Home/Index");
}
public ActionResult Index()
{
System.Web.Security.FormsAuthentication.SetAuthCookie("qsmy_qin", true);
return View();
}
public ActionResult Contact()
{
bool d=Request.IsAuthenticated;
return View();
}
{
System.Web.Security.FormsAuthentication.SetAuthCookie("qsmy_qin", true);
return View();
}
public ActionResult Contact()
{
bool d=Request.IsAuthenticated;
return View();
}