0

This is related to Link to "Download a Copy" from a Document Library

I use /_layouts/download.aspx?SourceUrl=/sites/sitename/library/folder/fileName.aspx to download files in my application. However, I get an access denied message, if try to download an ASPX file. It works with any other file type though. I am using SP 2016.

Is there a way to make it work with ASPX files?

EDIT: Sorry, I should've given more context: I'm using a Java console app. The Java console app copies all the files from a given library to the HDD. It works fine with any file type we have: docx, xls, pdf, etc., but not with ASPX. We used to use SP 2013, and now we have migrated the SP to SP 2016. SP 2013 supports HTML extensions - can be served as web pages, so we did not face any issue there. However with SP 2016, we can only use ASPX extensions for web pages. Now we get permission denied error when using: http://site/_layouts/download.aspx?SourceUrl=/sites/sitename/library/folder/fileName.aspx

  • 1
    Have you tried to download the same file using OOTB "Download a Copy" option without any permission issue? – Mohamed El-Qassas MVP Apr 18 '18 at 20:55
  • I am not sure what do you mean with out of the box "Download a Copy". Are you refering to downloading the file through the browser? – VitaminX Apr 19 '18 at 8:23
1

Add absolute URL for download.aspx in your <a> tag.

http://<site URL>/_layouts/download.aspx?SourceUrl=/sites/sitename/library/folder/fileName.aspx

If you are using Javascript. Use below code.

var downloadPageURL = _spPageContextInfo.webAbsoluteUrl + "/_layouts/download.aspx?SourceUrl=/sites/sitename/library/folder/fileName.aspx"
  • Sorry, I should've given more context: I'm using a Java console app. The Java console app copies all the files from a given library to the HDD. It works fine with any file type we have: docx, xls, pdf, etc., but not with ASPX. We used to use SP 2013, and now we have migrated the SP to SP 2016. SP 2013 supports HTML extensions - can be served as web pages, so we did not face any issue there. However with SP 2016, we can only use ASPX extensions for web pages. Now we get permission denied error when using: site/_layouts/download.aspx?SourceUrl=/sites/sitename/library/… – VitaminX Apr 19 '18 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.