I have a program that is developed in MVC 3 Razor Syntax but whenever I am posting to the controller with a file it doesn't work but if I just post to the controller without a file it works. What could be the problem ? Here's my Code:
@using (Html.BeginForm("UpdateFile", "AdministerFiles", FormMethod.Post,
new {enctype = "multipart/form-data"}))
{
string title = null;
string description = null;
string filename = null;
int dataid = 0;
int filesize = 0;
string filepath = null;
foreach (var fileDetails in ((RefDataLinks_mst[])@Model[1]))
{
title = fileDetails.DataTitle;
description = fileDetails.Description;
filename = fileDetails.DataFileName;
dataid = fileDetails.DataID;
filesize = fileDetails.FileSize;
filepath = fileDetails.DataFilePath;
}
<div id="updateLeftTopPart">
<label class="addFileLabel"for="title">Title : </label><textarea rows="3" cols="50" name="title" required>@title</textarea> <br /> <br />
</div>
<div id="updateRightTopPart">
<label for="description">Description : </label><textarea rows="2" cols="50" name="description" required>@description</textarea>
</div>
<div id="updateLeftPart">
<label>Existing File : </label><label><a href="/BrowseData/DownloadFile?catID=@catid&filename=@filename&filepath=@filepath">@filename</a></label>
</div>
<div id="updateUploadFile">
<label for="file">Upload New File Here :</label><input type="file" name="file" id="file"/>
</div>
<input type="hidden" value="@catid" name="catid"/>
<input type="hidden" value="@filename" name="existingFile"/>
<input type="hidden" value="@dataid" name="dataid"/>
<input type="hidden" value="@filesize" name="filesize"/>
<div id="updateActions">
<input type="submit" value="Update File" />
<input type="reset" value="Reset" />
</div>
}
These are the parameters of my Controller:
public ActionResult UpdateFile(HttpPostedFileBase file, int catid, int dataid, string title, string existingFile, string description, int filesize)
Whenever I post, The browser is saying that The connection to the server was reset while the page was loading. What could be the problem ?