Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html angularjs在IE8/9上通过POST下载文件,无需页面刷新_Html_Asp.net Mvc_Angularjs_Internet Explorer 8_Internet Explorer 9 - Fatal编程技术网

Html angularjs在IE8/9上通过POST下载文件,无需页面刷新

Html angularjs在IE8/9上通过POST下载文件,无需页面刷新,html,asp.net-mvc,angularjs,internet-explorer-8,internet-explorer-9,Html,Asp.net Mvc,Angularjs,Internet Explorer 8,Internet Explorer 9,我正在尝试使用隐藏表单从服务器下载动态生成的文件 下面是我用来提交隐藏表单的角度函数 $scope.downloadCsv = function() { var dataset = JSON.stringify($scope.dataset); var body = $('body'); var reportParamJson = angular.toJson($scope.dataset); var hiddenForm = "<form action='/Rep

我正在尝试使用隐藏表单从服务器下载动态生成的文件

下面是我用来提交隐藏表单的角度函数

$scope.downloadCsv = function() {
   var dataset = JSON.stringify($scope.dataset);
   var body = $('body');
   var reportParamJson = angular.toJson($scope.dataset);
   var hiddenForm = "<form action='/Reports/SaveTestCsv' method='POST' target='_blank'><input type='hidden' name='dataset' value='" + dataset + "'/ ><button id='submitCSV' type='submit'></button></form>";
   body.append(hiddenForm);
   $('#submitCSV').click();
}
$scope.downloadCsv=function(){
var dataset=JSON.stringify($scope.dataset);
变量body=$('body');
var reportParamJson=angular.toJson($scope.dataset);
var hiddenForm=“”;
body.append(隐藏形式);
$(#submitsv')。单击();
}
下面是用.NETMVC方法生成文件响应

[HttpPost]
public ActionResult SaveTestCsv(string dataset)
{
    var data = JsonConvert.DeserializeObject<MyObject>(dataset);
    var binary = getTestCSV(data);
    var file = File(binary, "text/csv", "test.csv");
    return file;
}
[HttpPost]
公共操作结果SaveTestCsv(字符串数据集)
{
var data=JsonConvert.DeserializeObject(数据集);
var binary=getTestCSV(数据);
var file=文件(二进制,“text/csv”、“test.csv”);
返回文件;
}
下面是部分html页面中的相关html代码,我使用ng include将其包含在视图中

<div><a href="#" ng-click="downloadCsv()">Download CSV</a></div>
<div ng-grid="gridOptions"></div>

当我点击“下载CSV”时,Chrome、FF和IE10会提示我保存文件而不刷新页面/视图,但在IE8/9上,页面被刷新,因此ng include标记的内容消失了,特别是我上面发布的html不再存在

我想知道这是否与IE8/9的url中的hashbang有关,有没有办法解决这个问题

编辑 我最终完全从angular中删除了路由,只使用.NETMVC为我做路由,然后它就可以在IE8上工作了