How to open custom aspx page in the browser instead downloading in SharePoint Online?

Open aspx File Online: How to open custom aspx page in the browser instead downloading in SharePoint Online?

No comments

Loading

Open aspx file Online – 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?

Solution: Open aspx file Online

In order to fix the above issue or to open the .aspx file in the browser instead of downloading it, we need to enable custom scripting on 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 the tenant-level through modern admin center UI (Open aspx file Online)

Go to your tenant setting page thru this URL

https://sprnd-admin.sharepoint.com/_layouts/15/online/TenantSettings.aspx

Note: Here “sprnd” is my tenant name, you need to pass your tenant name.

Open aspx file Online, Prevent users from running custom script on personal sites in SharePoint Online

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.

  1. Prevent users from running custom script on personal sites.
  2. Prevent users from running custom script on self-service created sites)
Open aspx file Online, Prevent users from running custom script on personal sites in SharePoint Online
Prevent users from running custom script on personal sites in SharePoint Online

Now select to allow users to run the custom script for both the radio button as below:

  1. Allow users from running custom script on personal sites.
  2. Allow users from running custom script on self-service created sites)
Allow users from running custom script on personal sites in SharePoint Online
Allow users from running custom script on personal sites in SharePoint Online

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(Open aspx file Online)?

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

Summary: Open aspx file Online

Thus, in this article, we have learned about how to enable custom scripting in SharePoint Online specific sites and fix the issue of opening a custom aspx page in the browser.

See Also: Open aspx file Online

You may also like the below SharePoint troubleshooting articles:

If this article helps you, please appreciate our efforts by writing a comment below or if you have a better idea/solution to this topic, please write a comment, we will include that in this article. Thank you, happy reading, learning, and Sharing. 🙂

 

 

About Post Author

Do you have a better solution or question on this topic? Please leave a comment