Ajax requests. The submission of data, the passing of parameters. FormCollection

Source: Internet
Author: User

<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&gt        ;             <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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.