using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc; namespace MvcApplication1.Controllers
{
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
//public List<KeyPair> Numbers { get; set; }
public object Numbers { get; set; }
} public class KeyPair
{
public string Key { get; set; }
public string Value { get; set; }
} public class HomeController : Controller
{
//
// GET: /Home/ public ActionResult Index()
{
return View();
} public void Post(Person data)
{
var numbers= data.Numbers as List<KeyPair>;
} }
}
@{
ViewBag.Title = "Index";
}
<button id="btn">TEST</button>
<h2>Index</h2>
<script src="~/Scripts/jquery-2.0.3.js"></script>
<script>
var data = {
Name: "tom",
Age: ,
Numbers: [{ Key: "a", Value: "A" }, { Key: "b", Value: "B" }]
};
$(function() {
$("#btn").on("click", function() {
$.ajax({
url: "/Home/Post",
type: "POST",
contentType: "application/json; charset=utf-8",
data:JSON.stringify(data),
dataType: "Json"
});
});
});
</script>

Model Binding的更多相关文章

  1. [ASP.NET MVC 小牛之路]15 - Model Binding

    Model Binding(模型绑定)是 MVC 框架根据 HTTP 请求数据创建 .NET 对象的一个过程.我们之前所有示例中传递给 Action 方法参数的对象都是在 Model Binding ...

  2. Asp.net MVC使用Model Binding解除Session, Cookie等依赖

    上篇文章"Asp.net MVC使用Filter解除Session, Cookie等依赖"介绍了如何使用Filter来解除对于Session, Cookie的依赖.其实这个也可以通 ...

  3. [ASP.NET MVC] Model Binding With NameValueCollectionValueProvider

    [ASP.NET MVC] Model Binding With NameValueCollectionValueProvider 范例下载 范例程序代码:点此下载 问题情景 一般Web网站,都是以H ...

  4. ASP.NET MVC3 Dynamically added form fields model binding

    Adding  new Item to a list of items, inline is a very nice feature you can provide to your user. Thi ...

  5. 【ASP.NET MVC 学习笔记】- 16 Model Binding(模型绑定)

    本文参考:http://www.cnblogs.com/willick/p/3424188.html. 1.Model Binding是Http请求和Action方法之间的桥梁,是MVC框架根据Htt ...

  6. .NET Core开发日志——Model Binding

    ASP.NET Core MVC中所提供的Model Binding功能简单但实用,其主要目的是将请求中包含的数据映射到action的方法参数中.这样就避免了开发者像在Web Forms时代那样需要从 ...

  7. 运用模型绑定和web窗体显示和检索数据(Retrieving and displaying data with model binding and web forms)

    原文 http://www.asp.net/web-forms/overview/presenting-and-managing-data/model-binding/retrieving-data ...

  8. [置顶] ASP.NET MVC - Model Binding

    Http Request 到Input Model的绑定按照model的类型可分为四种情况. Primitive type Collection of primitive type Complex t ...

  9. Model Binding To A List

    [文章来源see here] Using the DefaultModelBinder in ASP.NET MVC, you can bind submitted form values to ar ...

  10. MVC3 Model Binding验证方式

    1.使用ModelState在Action中进行验证 [HttpPost] public ViewResult MakeBooking(Appointment appt) { if (string.I ...

随机推荐

  1. Ruby零星笔记

    chomp:去掉字符串末尾的\n或\r chop:去掉字符串末尾的最后一个字符,不管是\n\r还是普通字符 to_s:转换成字符串 to_i:转换成数值 object.nil?:判断是否为空,空返回: ...

  2. support HTML5 in IE8

    <!--this code is used to support HTML5 in IE8--> <!--[if IE]><script type="text/ ...

  3. jQuery extend 实现代码封装

    jQuery 有两种方式封装代码 $.extend 和 $.fn.extend,我们也称为封装插件 $.extend DEMO // 封装 $.extend({ say:function(option ...

  4. 学习mysql

    一 概述 1.什么是数据库 数据库就是数据的仓库. mysql是对数据库进行存储和指令操作的软件.这类软件成为数据管理系统Database Management System. 2.mysql的安装和 ...

  5. .NET 框架基本原理透析⑴

    .NET框架的核心便是通用语言运行时(CLR),顾名思义它是一个可被各种不同的编程语言所使用的运行时.CLR的很多特性可用于所有面向它的编程语言.比如,如果CLR用异常来报告错误,那么所有面向它的语言 ...

  6. vim - Highlight unwanted spaces

    http://vim.wikia.com/wiki/VimTip396 precondition: set hlsearch" Show all tabs:/\t" Show tr ...

  7. SQL Server 索引中include的魅力(具有包含性列的索引)

    2010-01-11 20:44 by 听风吹雨, 22580 阅读, 24 评论, 收藏, 编辑 开文之前首先要讲讲几个概念 [覆盖查询] 当索引包含查询引用的所有列时,它通常称为“覆盖查询”. [ ...

  8. dyld: Library not loaded: /System/Library/Frameworks/UserNotifications.framework/UserNotifications解决办法

    这个问题产生的原因是:在iOS 10中有UserNotifications这个framework而iOS 9中没有,在iOS 9上运行的时候,会因为找不到而出错. 解决办法是,修改UserNotifi ...

  9. HTTPS强制安全策略-HSTS协议阅读理解

    https://developer.mozilla.org/en-US/docs/Web/Security/HTTP_strict_transport_security [阅读理解式翻译,非严格遵循原 ...

  10. js接受url参数

    1.正则表达式 function getQueryString(name) { var reg = new RegExp("(^|&)" + name + "=( ...