15,230 total views, 78 views today
Many times we might observe strange behavior in modern SharePoint Online while we upload a custom .aspx file in SharePoint Pages or Site Pages library, and try to open it in the browser – what will happen is, it will be downloading the .aspx file instead of browsing – so, in this article, we will learn about how can we open the aspx page or file in the browser instead of downloading the file?
In order to fix the above issue or to open the .aspx file in the browser instead of downloading, we need to enable custom scripting in that said site.
Below is the PowerShell script using which we can enable the custom scripting feature in the modern SharePoint Online site.
It is a two steps process, first, we need to enable the custom scripting at the tenant level, then at the site level.
Enable custom scripting at tenant-level through modern admin center UI
Go to your tenant setting page thru this URL
Note: Here “sprnd” is my tenant name, you need to pass your tenant name.
Now see the “Custom Script” section by default both the radio button is selected as prevent – this is the default behavior and due to this script editor and content editor web part is missing from SharePoint online page.
- Prevent users from running custom script on personal sites.
- Prevent users from running custom script on self-service created sites)
Now select to allow users to run the custom script for both the radio button as like below:
- Allow users from running custom script on personal sites.
- Allow users from running custom script on self-service created sites)
Now click on ok and once you save it, this may take 24 hours to reflect the changes.
How to enable the custom scripting using the PowerShell script?
Execute the below PowerShell script to enable the custom scripting in SharePoint Online (specific site).
$adminUserID="youradminaccount@< sprnd.onmicrosoft.com>" $userCredential = Get-Credential -UserName $adminUserID -Message "Enter password" Connect-SPOService -Url https://sprnd-admin.sharepoint.com/ -Credential $userCredential Set-SPOsite "https://sprnd.sharepoint.com/sites/TestSite001" -DenyAddAndCustomizePages 0
Thus, in this article, we have learned about how to enable custom scripting in SharePoint Online specific site and fix the issue of opening a custom aspx page in the browser.
You may also like the below SharePoint troubleshooting articles:
- SharePoint Online – O365: How to enable script editor web part in SharePoint online
- [Fixed] Error – activate the SharePoint Server Publishing Infrastructure feature in SharePoint Online site
- [Fixed] Server relative urls must start with SPWeb.ServerRelativeUrl”in reading web part properties!
- [Fixed]: The page could not be created. Custom Scripting might be deactivated on the destination site or you might not have sufficient permissions.
- [Fixed] The upgraded database schema doesn’t match the TargetSchema(Failed to upgrade SharePoint Products)
- [Fixed] “Sorry, something went wrong. There was an exception in the Database” (SharePoint Server Error)
- [Fixed] How to fix the “Unexpected response from server. The status code of response is ‘500’ in SharePoint 2016 Search error.”?
- [Fixed] How to fix the wrong tenant credential error in SharePoint online?
- [Fixed] How to fix request timed out error in SharePoint 2016 search (There was no endpoint listening)?
- [Fixed] How to Fix a SharePoint 404 Error in sub site After Restoring a Content Database?