<1>
<%@ page language= "C #" inherits= "system.web.mvc.viewpage<dynamic>"%><2>
Controller
Using system;using system.collections.generic;using system.linq;using system.web;using System.Web.Mvc;using System.text;namespace Bigtree. controllers{using Bigtree. Models; Using Bigtree. Model; Using Bigtree.lib; Using System.Net.Mail; Using System.Text.RegularExpressions; public class Logincontroller:controller {public ActionResult Index () {return View (); }///<summary>///check-in//</summary>//<param name= "F" ></param> ; <returns></returns> [HttpPost] public actionresult checklogininfo (formcollection f) { try {//post:user, pwd, remembered string user = f["user"]. Trim (); string pwd = f["pwd"]. Trim (); String remembered = f["remembered"]. Trim (); Jsonresult res = new Jsonresult (); if (string. IsNullOrEmpty (user) | | String.IsNullOrEmpty (PWD)) {Res. Data = new {status = 0}; }//md5 encrypted password pwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFi Le (PWD, "MD5"). ToLower (); Read from database Common.webuser account = Memberinfoservice.getmemberidforcheck (user, PWD); if (account = = null) {Res. Data = new {status = 0}; } else {//{status:1 (Success)/0 (fail),} res. Data = new {status = 1}; TODO: Login success, record login user information save login status funsession.setsession (account); Whether to remember login if (remembered = = "on") {HttpCookie cookie = new Ht Tpcookie ("Logininfo", account. Id.tostring ()); 3-Day Valid cookie. Expires.adddays (3); RESPONSE.COOKIES.ADD (cookie); } else {HttpCookie cookie = new HttpCookie (account. Id.tostring (), account. Id.tostring ()); Make the cookie invalid. Expires.addyears (-1); RESPONSE.COOKIES.ADD (cookie); }} return res; } catch (Exception ex) {throw ex. innerexception; } } }}
Ajax requests. The submission of data, the passing of parameters. FormCollection