1

HI there,

My model (partial)

    public class Document : HttpPostedFileBase
    {
        public string DocumentTitle { get; set; }
        public string DocumentType { get; set; }

My action

   [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult AddDocumentToVault(Document model)
    {
        foreach (string upload in Request.Files)
        {
            if (!Request.Files[upload].HasFile()) continue;
            _documentAggregator.Add(model);
            _documentAggregator.Commit();
        }
            return PSDocumentVaultPartial();
    }

File uploader

<% using (Html.BeginForm("AddDocumentToVault", "PersonalSpace", FormMethod.Post, new { enctype = "multipart/form-data" }))
               {%>
                <input type="file" id="Document" runat="server" name="Document"/>
                <input id="AddDocument" type="submit" value="Upload" style="display:none"/>
        <% } %>

The problem I am having is that when the AddDocument button is pressed it's passing an empty model to the action in my controller. And the base properties in HttpPostedFileBase give a System.NotImplementException.

Can anyone tell me what I need to do to correctly pass my model to my action?

1 Answer 1

3

It's an issue with HttpPostedFileBase and model binding. See ASP.NET MVC posted file model binding when parameter is Model

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.