Logic of login interface
<1> Create a web page tag for the form
<form method="post" id=""> <input type="text" id="UserNuber"> <input type="text" id="passwo"> </form> <button id="btnSubmit" />
(2)
First write the click event of the login button, and then obtain its user name, password, verification code, identity and remember my values; Then judge them
Whether to fill in the data. If it is empty, it means that the information has not been filled in. Open the loading layer.load() and use post to request the path of the main page to obtain
The name of the value transmitted from the controller and the page should be the same; Then close the loading layer, confirm that the user information is correct, and then log in and jump successfully
Go to the main page, otherwise you will be prompted to say: "please fill in the correct user type" or "please enter the correct account and password", otherwise the user does not exist
Login failed.
$('#Button name '). click(function()){ var UserNuber=$('#Value in account input '). val() var password=$('#Value in password input '). val() if (strVlsnotNull(Upper variable)&strVlsnotNull(Upper variable)) //Open load layer var layerIndex=layer.load(); $.post("Added folder suffix 1, { #Variables to add },function(msg){ #Close load layer layer.close(layerIndex); if(msg="success"){ window.location.replace("Folder suffix 2") }else{ if(msg=="User name error"){ layer.alert("Prompt 1") }else if(msg=="Password error"){ layer.alert("Prompt 1") } } }") }
(3)
When requesting a path, the path name should be the same as that of the controller, otherwise an Error 404 will be reported. The requested path does not exist or is less
The slash "/" in front of them can't be less than one, because this is a problem of format and can't be changed.
If the symbol "~" means the root directory, we will add it on the post request path when uploading pictures or files
Put on this symbol.
[Cookie]
The following figure shows the code on the controller side. First leave the user name and password blank, and then remember that my status is false to get it
Cookie; so what's the cookie here? It's usually used to identify users. Cookie is a kind of server left on our users' computers
Whenever we send a request page through the browser, our computer will send a cookie.
[session] The session is different. When we are browsing some web pages, we close the web page after a period of time
When we open the browser again, we will find that it will automatically help you open the web page you visited last time. This is its magic. When cookies
It is transmitted to the user's computer, which contains information that can identify the user. Then this interface is used as a Session object
Save the information of the user session or change the settings of the user session.
Common codes are as follows:
public ActionResult Login() { string user name=""; string password=""; #This is a direct call to the coockies file in user HttpCookie cookie=Syetem.Web.HttpContext.Current.Request.Cookies["user"]; if(cookie["user name"]!=null) { UserNuber=System.Web.HttpContext.Current.Server.UrlDecode(cookie["account"]); } if(cookie["password"]!=null) { Password=System.Web.HttpContext.Current.Server.UrlDecode(cookie["password"]); } isRember=true; } ViewBag.UserNuber=UserNuber; ViewBag.Password=Password