문제

Currently I've got a runtime exception: 'Systen.MissingMethodException : No parameterless constructor defined for this object.

I've googled and came across a lot of people actually not having a default contstructor, though my code actually does, so I don't know where it goes wrong!

My full code can be found here on pastebin since its varely large: http://pastebin.com/RxdKgxSx

Thanks for your help!

도움이 되었습니까?

해결책

Replace:

public ActionResult Create(UploadViewItem viewItem, HttpPostedFile postedFile)

with:

public ActionResult Create(UploadViewItem viewItem, HttpPostedFileBase postedFile)

ASP.NET MVC works with abstractions over the actual HttpContext objects (HttpContextBase, HttpRequestBase, HttpResponseBase, HttpSessionBase, HttpPostedFileBase, ...).

That's what allows for easier unit testing and mocking those objects.

For more information about uploading files in ASP.NET MVC you may checkout the following blog post.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top