首页 > 代码库 > Ajax请求。数据的提交,参数的传递。FormCollection

Ajax请求。数据的提交,参数的传递。FormCollection

<1>

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

<head runat="server">
    <title>ajax请求</title>
    <link type="text/css" rel="stylesheet" href=http://www.mamicode.com/"/Content/style.css" />>

<2>

控制器

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>
        /// 检查登陆
        /// </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 = http://www.mamicode.com/new { status = 0 };>

Ajax请求。数据的提交,参数的传递。FormCollection