MVC Part
return File(stream, "application/vnd.ms-excel", file.FileName);
I'm returning file from MVC controller in above way.
AngularJS controller
$scope.ExcelValidate = function () {
if ($scope.files && $scope.files.length && $scope.selectedFileType != -1) {
busyIndicatorService.showBusy("Uploading data...");
for (var i = 0; i < $scope.files.length; i++) {
var file = $scope.files[i];
$scope.file = file.name;
Upload.upload({
url: '/MasterExcelImport/ValidateExcelData',
fields: {
uploadType: $scope.selectedFileType.Key.Key
},
file: file
}).progress(function (evt) {
console.log('percent: ' + parseInt(100.0 * evt.loaded / evt.total));
$scope.file.progress = parseInt(100.0 * evt.loaded / evt.total);
}).success(function (data) {
busyIndicatorService.stopBusy();
var blob = new Blob([data], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
var objectUrl = URL.createObjectURL(blob);
window.open(objectUrl);
}).error(function (data, status, headers, config) {
busyIndicatorService.stopBusy();
});
}
}
};
Return file already comes to the success section. But downloading part got failed.
Could someone help me to resolve this issue please?
Thanks, Erandika Sandaruwan