I have a problem with downloading files with Ajax.BeginForm
.
I know, this is not a good idea, but i really need to download using it
I have a Controller
, where the file is being generated and I need to download it.
There is example, how i trying to make that:
@using (Ajax.BeginForm("GenerateFromFile", "WsdlGenerator", new AjaxOptions
{
HttpMethod = "Get",
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "target",
LoadingElementId = "loader",
OnSuccess = "OnSuccess",
OnBegin = "OnBegin",
OnComplete = "OnComplite"
}, new { enctype = "multipart/form-data", @class = "form-horizontal", role = "form" })){
<div class="col-md-4 col-md-offset-3">
<input id="download-button" type="submit" value="Generate" name="Generate" class="btn btn-primary btn-lg" />
</div>
</div>
<div class="circleLoad" id="loader" style="display:none">
Ваш запрос выполняется...
</div>
}
@section Scripts {
<script type="text/javascript">
function OnSuccess(response) {
}
function OnBegin() {
// dowloadThisPerfectFile();
}
function OnComplite(url) {
}
pageLoad();
//
</script>
}
How can i download it with Ajax ? Thanks !