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...