.NET的Ajax请求数据提交-创新互联

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

目前成都创新互联已为1000+的企业提供了网站建设、域名、网络空间、网站改版维护、企业网站设计、东平网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。

  ajax请求

 

 

 

 

 

     

 

 

 

     

         

     

         

              会员登录没有账号?立即注册

         

         

             

                 

             

             

                 

                 

             

             

用户名或密码错误!

             

                 

                     

                      自动登录

                  忘记密码?

             

             

         

         

     

 

控制器

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();

      }

      ///

      /// 检查登陆

      ///

      ///

      ///

      [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加密后的密码

              pwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(pwd, "md5").ToLower();

              //从数据库读取

              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 };

                  //codego.net/#todo:登陆成功,记录登陆用户信息保存登陆状态

                  FunSession.SetSession(account);

                  //是否记住登录

                  if (remembered == "on")

                  {

                      HttpCookie cookie = new HttpCookie("LoginInfo", account.Id.ToString());

                      //3天有效

                      cookie.Expires.AddDays(3);

                      Response.Cookies.Add(cookie);

                  }

                  else

                  {

                      HttpCookie cookie = new HttpCookie(account.Id.ToString(), account.Id.ToString());

                      //使失效

                      cookie.Expires.AddYears(-1);

                      Response.Cookies.Add(cookie);

                  }

              }

              return res;

          }

          catch (Exception ex)

          {

              throw ex.InnerException;

          }

      }

  }

}

创新互联www.cdcxhl.cn,专业提供香港、美国云服务器,动态BGP最优骨干路由自动选择,持续稳定高效的网络助力业务部署。公司持有工信部办法的idc、isp许可证, 机房独有T级流量清洗系统配攻击溯源,准确进行流量调度,确保服务器高可用性。佳节活动现已开启,新人活动云服务器买多久送多久。


分享题目:.NET的Ajax请求数据提交-创新互联
转载来于:http://pwwzsj.com/article/cscshe.html