Note that there are some explanatory texts on larger screens.

plurals
  1. POFileUpload in Ajax Form in ASP.NET MVC Partial View Not Working
    primarykey
    data
    text
    <p>I have 2 file upload for editing user profile in partial view that called from user profile page. The problem is <code>HttpPostedFileBase</code> parameter in action method always <code>null</code>.</p> <p>When I'm calling this partial view out of profile page and without layout, file uploads was successfully done and sent files to action method.</p> <p>This is my action method in controller:</p> <pre><code>[AcceptVerbs(HttpVerbs.Post)] [Authorize(Roles = "User")] public ActionResult EditProfile(ProfileGeneralDescription editedModel, HttpPostedFileBase imageFile, HttpPostedFileBase coverFile) { //Some code here... } </code></pre> <p>And this is my partial view <code>cshtml</code> code:</p> <pre><code>@model Website.Models.ViewModel.Profile @using (Ajax.BeginForm("EditProfile", "Profile", new { postOwnerUser = User.Identity.Name }, new AjaxOptions() { HttpMethod = "POST", InsertionMode = InsertionMode.Replace, UpdateTargetId = "GeneralSection" }, new { enctype = "multipart/form-data" })) { &lt;div&gt; &lt;button type="submit" name="Save" class="btn btn-default btn-xs"&gt;Save Changes&lt;/button&gt; @Ajax.ActionLink("Cancel", "ProfileDescription", "Profile", new {username = Model.Username, type = "Show"}, new AjaxOptions() { HttpMethod = "GET", InsertionMode = InsertionMode.Replace, UpdateTargetId = "GeneralSection" }, new {@class = "btn btn-default btn-xs"}) &lt;/div&gt; &lt;input type="hidden" name="username" id="username" value="@Model.Username"/&gt; &lt;fieldset&gt; &lt;legend&gt;Edit Photos&lt;/legend&gt; &lt;div&gt; Select profile picture: &lt;input id="imageFile" type="file" name="imageFile" accept="image/png, image/jpeg" /&gt; @Html.CheckBoxFor(modelItem =&gt; modelItem.DefaultCover)&lt;span&gt;Remove profile photo&lt;/span&gt; &lt;/div&gt; &lt;div&gt; Select cover picture: &lt;input id="coverFile" type="file" name="coverFile" accept="image/png, image/jpeg" /&gt; @Html.CheckBoxFor(modelItem =&gt; modelItem.DefaultCover)&lt;span&gt;RemoveCover&lt;/span&gt; &lt;/div&gt; &lt;/fieldset&gt; } </code></pre> <p>Where is my mistake?<br/> Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload