dhl:mvc用户登陆身份验证

登录:
[HttpPost]
        public ActionResult LoginSuccess()
{

bool rememberMe = Request["rememberMe"].Contains("true");
UserAccount account = ia.GetUserAccountByUserName(brief.UserName);

//验证成功
                    string usercookie = account.UIN + "," + brief.UserName;
                    FormsAuthentication.SetAuthCookie(usercookie, rememberMe);

}

 

注销:

        public ActionResult LoginOut()
        {
            FormsAuthentication.SignOut();
}

 

判断是否登陆:

 [AuthorizeAttribute]
        public ActionResult Payment(int? lid,long? classid)
        {}

 

webcofig:

  <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="2880" />
      
    </authentication>

 

没有登录时候

ie地址栏:

http://localhost/Account/Login?ReturnUrl=%2fShoppingCart%2fpayment%3flid%3d1%26classid%3d10010%26type%3dbuy&lid=1&classid=10010&type=buy

 

 

 

 

原文地址:https://www.cnblogs.com/dudu837/p/1856843.html