网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

.NET的Ajax请求数据提交

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

专注于为中小企业提供成都网站设计、成都网站制作服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业尚义免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了上千多家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。

  

 

    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;  

            }  

        }  

    }  

}


新闻名称:.NET的Ajax请求数据提交
链接地址:http://bjjierui.cn/article/pjcpsc.html

其他资讯