1

We have one aspx page uploaded in the Document Library with basic html tags(including html and body tag). when we try to open the aspx page it redirects to /_layouts/15/download.aspx page

we have also tried the setting- use the server default(open in browser)/Open in browser in the library advance settings and tried to upload the aspx page using the upload option instead of drag and drop.

5 Answers 5

4

If you put an ASPX file to a document library it will be downloaded when you click on it.

So, instead of the document library, you need to put your ASPX page to a different location. For example:

  • Site Assets
  • Styles Library
  • Site Pages

If you put your HTML Page (with an aspx extension) to any of the above, it will open just fine.

However, there is one caveat. By default, "Add And Customize Pages" right is denied on the modern site collections. This is why you have to disable this security feature before you can upload a custom ASPX page:

Install-Module -Name Microsoft.Online.SharePoint.PowerShell    
Connect-SPOService -Url https://tenant-admin.sharepoint.com 
Set-SPOSite -Identity https://tenant.sharepoint.com/sites/ModernTeam -DenyAddAndCustomizePages $false

enter image description here

enter image description here

1
  • Thanks for providing the solution. After providing "Add And Customize Pages" permissions the .aspx page is working in all document libraries. Jan 1, 2020 at 9:54
2

What’s the permission of the user?

Make sure the user have "Add and Customize Pages permission" via checking permission in the site settings->site permissions->check permission.

If the issue still exists, how did you create the aspx page? Try to go to SharePoint Designer 2013 ->site pages->Page->create a new aspx page and check if it can be opened in the browser.

enter image description here

1

This seems to be more difficult now (as of Nov 2021) but is still possible...

I re-encountered this problem today (Nov 2021), I tried all the above solutions (and others) but could just not get the page to render. I did eventually find a way to get this working though, please see steps below to get an .aspx page to load in SharePoint...

NB: For the purposes of this explanation:

  • OfflinePage.aspx is the page on my local machine I want to upload/render on SharePoint
  • OnlinePage.aspx is the page I will create directly in SharePoint to do this -- see the below steps for more info...

(only) solution that worked for me...

  1. Buildng on @Hellofiona_MSFT's solution, connect to the site with SharePoint Designer 2013
  2. Open the Site Pages library
  3. Create a new (blank) ASPX page OnlinePage.aspx

enter image description here

  1. Edit OnlinePage.aspx using the Advanced Edit mode
  2. Copy code from my OfflinePage.aspx (the page I want to upload/render in SharePoint)
  3. Paste into OnlinePage.aspx (over the auto-generated code)

Other methods tried unsuccessfully (had no effect)...

  • Set-SPOSite -DenyAddAndCustomizePages $false (this was already set)
  • ❌ Granting Add and Customize Pages permissions (I am Global Admin and Site Collection Admin)
  • ❌ Uploading an .aspx file to SiteAssets (still would not render)
  • ❌ Uploading an .aspx file to SitePages (this seems to be blocked now)
0

Just to help out others who might see this: You can simply drag & drop files/folders into the Site Pages section in SharePoint Designer 2013. At least that's what worked for me (after finding out that I can't log in with a user that has MFA enabled etc...).

0

An alternative approach is to upload your page to OneDrive for Business and then move it to the required site. I put some into a folder in the Shared Documents library and they worked fine.

You will note that SharePoint adds some extra code for you when you do this. Once you have that code, you can simply copy across to new pages so that you can create them directly in the folder. I link the folder to my ODfB and then I can edit using VScode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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