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:

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

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -