Forum Discussion
Rohit Devmore
Jul 28, 2017Copper Contributor
Crazy ASPX page behavior in Sharepoint Online document library , getting downloaded
We have two site collections in Sharepoint online and those have respective document libraries (Say Lib1 (Site collection 1) and Lib2 (Site collection 2))
We have ASPX page on drive which are uploading through powershell inside document library.
Upload through powershell
- Lib1 = ASPX page uploads and opens fine in the browser
- Lib2 = Same ASPX page uploads however it does not open in browser and gets downloaded
Upload manually/ Drag drop
- Lib1 = ASPX page uploads and opens fine in the browser
- Lib2 = Same ASPX page uploads and opens fine in the browser
I am really puzzled. whats making Lib2 to download the aspx page when uploaded through power-shell.
Have you seen such issue before?
Dont think its an issue with Powershell script, as its working fine on Lib1.
Not issue with library also, as when manully ASPX is uploaded manully it opens fine in browser
- tapansamCopper Contributor
Rohit Devmore - Thanks for your post. I also stumbled across similar behavior of ASPX file in a Document library in SharePoint Online. Initially, I followed most of the suggestions to solve this.
Unfortunately, the issue remains same - ASPX files are downloaded in all browsers instead of rendering in browser. Even if I try to access the ASPX file with direct link SharePoint show 'Something went wrong' - 'File not found'. Here is the URL format I tried: https://[tenant].sharepoint.com/teams/team1/testlibrary/myfile.aspx
After my analysis, I found that the ASPX files should be uploaded by 'Site Owners' and not by the members or of the site. Once I re-uploaded the ASPX files as a 'Site Owner' using the standard upload feature in document library all of the ASPX files are being rendered in all browsers instead off download prompt.
It looks like SharePoint internally assign some internal flags for the ASPX files uploaded by Site Owners. If we try to 'Copy Link' we can see the differences between the files uploaded by Site Members and Site Owners.
Here is an example:
Link copied for file uploaded by Site Owner - https://[tenant].sharepoint.com/:u:/r/teams/team1/testlibrary/myfile.aspx?csf=1&e=fi6Pme
On the other hand link copied for file uploaded by Site Member - https://[tenant].sharepoint.com/teams/team1/_layouts/15/download.aspx?UniqueId=[GUID]&e=ZepFn
The later link clearly instruct the browser to download the file.
This saves my day. I thought this might help others whosoever face similar issues in SharePoint Online.
Br/Tapan
- SPWadeCopper Contributor
tapansam Unfortunately, I don't believe this is the whole story as I am a member of the Owners group of a site but still cannot get aspx to run. I believe that the site must allow scripts to run, also. Here's a SO post that goes into it a little: https://sharepoint.stackexchange.com/questions/237928/how-do-i-allow-the-documents-library-in-an-office-365-group-site-allow-aspx-page
- SPWadeCopper Contributor
SPWade In fact, let me just follow up on this a little more. Unless you have Allow Custom Scripts turned on / enabled for your site you are only going to be able to create a new aspx page via the UI (or Designer) and that page will only be allowed to run certain web parts on it. Once you try editing the page and putting any custom script on it (or just editing what's already there and adding a simple space, then saving), it will break. Even the Page Viewer webpart is not going to work for viewing, say, an HTML page or a 3rd party page without custom scripts enabled.
Obviously, this is a security lockdown because someone with editor access to a page could put in some hidden script that acts on behalf of the user to, say, post some of their information to a list or activate a workflow.
The only alternatives I can see are a) enable custom scripts, b) put your customizations into an Add-In (App) and publish them to the SP store so they are trusted, c) redirect the user away from SP to an external system that hosts the content (and optionally use the SP API to interact with data - again, sorta the App approach without the overhead of dealing with, say, SP admins), or even d) have the user sync a folder with the content down to their local system and launch the content from there. Again, that's just another variation on external hosting. And is probably a nightmare to support.
Or, e) find a new environment to work in where you don't have all the ridiculous restrictions and vulnerabilities (worldwide MSFT outages, anyone?) of SP. 5000 item list limits - from 1998 - and explaining why they are ridiculous to SP admins is so fun and productive!
- Rafael Martins HerculanoCopper Contributor
I have the exactly same issue ...
Anyone knows how to solve this ?
- Steven DerveauxCopper Contributor
Same issue here. In one Site Collection I can view my ASPX pages, in another (a Microsoft Teams SharePoint site) the file is prompted for download...
- Steven DerveauxCopper ContributorI just set the flag "DenyAddAndCustomizePages" to 0 via the powershell cmdlet:
Set-SPOsite https://xxx.sharepoint.com/sites/teamxyz -DenyAddAndCustomizePages 0
I'll cross my fingers if this is working. The value on this flag is often cached. So I will check back tomorrow!
- John Aage AndersenIron Contributor
Which content types does the ASPX file get in each library? Are they the same?
Kind regards
John
- Rohit DevmoreCopper ContributorThank you John. I feel stupid to say this, however this has started working now after continuous attempts. I have failed to identify what the issue was . TO answer your question, Content type is Documents, however not sure what the difference is between Uploading manually and through the script. Fortunately its working now.
- John Aage AndersenIron ContributorThanks for the feedback! Good to hear it started to work :)
- Well, I have not seeing this and it seems to be very weird according to your description of the scenario you have
- Rohit DevmoreCopper ContributorThank you Juan. I feel stupid to say this, however this has started working now after continuous attempts. I have failed to identify what the issue was