解决方案 »

  1.   

    不需要用什么控制器,直接通过Request["cn"]取值就好了
      

  2.   

     public JsonResult GetJSON(Video myVideo)
            {
               // rp.AddViedo(myVideo); 具体操作
               return Json("");
            }
      

  3.   

    LZ这个是用js给Video对象赋值么,这个是不可行的
      

  4.   

    LZ如果想要GetJSON(Video myVideo) 的myVideo有值,应该像如下操作假设是index.cshtml @model 项目名称.Controllers.HomeController.Video<script src="../../Scripts/jquery-1.7.1.min.js"></script>
    <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")"></script>
    @using(Html.BeginForm())
    {
        @Html.TextAreaFor(model=>model.time)
          @Html.TextAreaFor(model=>model.en)
          @Html.TextAreaFor(model=>model.cn)
        <input id="save" type="submit" value="submit" />
    }
       
     
           
            public ActionResult Index( )
            {
                return View();
            }
            [HttpPost]
            public ActionResult Index(Video v)
            {
                string time = v.time;
                string en = v.en;
                string cn = v.cn;
                return Json("json数据");    
            }
    MVC项目经验我也只有半年左右,但据我所知上面是最常用的操作流程
      

  5.   

    谢谢,你说的方式会导致页面回传刷新我现在做的是jquery ajax的调用,谢谢还是没有解决问题
      

  6.   

     public ActionResult GetJSON(Video myVideo)是需要.cshtml页面@model是强类型的Video类。通过六楼的所说的当时提交。
    楼主想通过data: JSON.stringify(myVideo) 方式提交应该是data:{"K":"V"},cs中通过Request对象找到K对应的json(V)在解析为Video。
      

  7.   

    空字符串改成null不好么?自己加个判断不就好public ActionResult GetJSON(Video myVideo)
    {
         if(myVideo.cn == null) myVideo.cn = string.Empty;
         // rp.AddViedo(myVideo); 具体操作
         return null;
    }
      

  8.   


    哈哈自己搞定了,就是给属性增加  [DisplayFormat( ConvertEmptyStringToNull = false )]  [DisplayFormat( ConvertEmptyStringToNull = false )]
                要是不添加这个属性,一旦view页面的传递""过来,框架会自动把空字符转换为null
                            DisplayFormatAttribute.ConvertEmptyStringToNull属性:是否将空字符串值 ("") 自动转换为null.默认值为 true
                http://msdn.microsoft.com/zh-cn/library/vstudio/system.componentmodel.dataannotations.displayformatattribute.convertemptystringtonull(v=vs.100).aspx