I create MVC 3 application in vs 2010. I try to a download a file in the filder.
this is my Action in MVC. Please see my code.
//[HttpPost]
public FileResult Download(string url, string cnt)
{
if (!string.IsNullOrEmpty(url) && !string.IsNullOrEmpty(cnt))
{
return File(url, cnt);
}
else
{
return null;
}
}
<input type="button" id="@(Model.ControlID)_bio_view" class="changepasswordbutton" value="View" />
And i create a jQuery function in my .cshtml file
function ViewFile(url, cnt) {
$.post('@(Url.Action("Download"))?url=' + url + '&cnt=' + cnt)
}
$('#@(Model.ControlID)_bio_view').click(function (e) {
ViewFile($('#bio_file_url').val(), $('#bio_file_url').attr("cnttype"));
});
This function is fired correctly when i click the Download button. But no file download window is prompted.
Please help.