javascript - document.location modifies WebApi route when trying to download file -
i have application built angularjs , webapi. i'm trying download file when button pressed. code ng-click:
$scope.download = function (documentobj) { if (documentobj && documentobj.filename) { var urlparams = "sid=" + documentobj.idstudy + "&fid=" + documentobj.idrequiredfile + "&fname=" + documentobj.filename; document.location = "api/document/download?" + urlparams; } };
this working in chrome , mozilla not in ie. in ie. have noticed url webapi different in ie after running code. more specifically:
the view i'm working in has url: http://localhost:54094/admin/studies/edit/1 after call ng-click function should start download see following results:
- chrome:http://localhost:54094/api/document/download?sid=71&fid=4&fname=basis%20kht%202016.sql
- ie:http://localhost:54094/admin/studies/edit/api/document/download?sid=71&fid=4&fname=basis kht 2016.sql
thus, in ie, correct webapi service not called.
what missing or not doing right? tips appreciated.
thank you.
should use absolute path not relative one...just add /
document.location = "/api/document/download?" + urlparams;
browser api
directory in root of site assuming have not used <base>
tag in page
Comments
Post a Comment