没有为此对象定义的无参数构造函数

没有为此对象定义的无参数构造函数

本文介绍了没有为此对象定义的无参数构造函数。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试实现简单的文件上传



I try to implement simple file upload

public class Movie
   {
       public int id { get; set; }
       public string name { get; set; }
       public string duration { get; set; }
   }







我的观点






My View

@model MvcApplication1.Models.Movie
@{
    ViewBag.Title = "FileUpload";
}

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

    <fieldset>
        <legend>Movie</legend>
        <div>
            @Html.LabelFor(m=>m.name)
            @Html.TextBoxFor(m=>m.name)
        </div>
        <div>
            @Html.LabelFor(m=>m.duration)
            @Html.TextBoxFor(m=>m.duration)
        </div>

        <div>
            <input type="file" name="fileUpload" />
        </div>

        <p>
            <input type="submit" value="Upload movie" />
        </p>
    </fieldset>
}







[HttpGet]
        public ActionResult FileUpload()
        {
            return View();
        }

        [HttpPost]
        public ActionResult FileUpload(Movie OMovie, HttpPostedFile postedFile)
        {
            var file = postedFile;
            return Content("You got the file.");
        }





但是我收到了错误





But i got error

[MissingMethodException: No parameterless constructor defined for this object.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +113
   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +232







请帮忙......




please help...

推荐答案




这篇关于没有为此对象定义的无参数构造函数。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-02 04:44