How can I open the aspx file in the browser instead of downloading the file?

After uploading the files and clicking on the aspx file the aspx file is downloaded. This may happen when your SharePoint Online site has "Enable Custom Script" disabled.

How can I avoid this?

Use one of the following methods:

  1. Upload the aspx file using your browser’s upload button.
    i.e. do not use “drag and drop” or sync via OneDrive for Business client.
  2. Use the optional Explorer App 2.0 (only for SharePoint Online Modern View)
    This is a so-called SPFx App that is installed via the SharePoint App catalog and this app adds a button to the ribbon in document libraries, picture libraries and asset libraries.
    Download the App from our web site
    and install the App.
    Note: the Explorer tool (aspx file) must be installed in the SiteAssets library in your SharePoint system for the Explorer App to work.
  3. Allow use of scripts in SharePoint Online using the admin web interface (up to 24 hrs delay)
    See “How to Enable Custom Script in SharePoint Online?

    To allow custom script in SharePoint Online, follow these steps:
    a. Sign in to Office 365 and go to the SharePoint Online Admin Center.
    b. Click on Settings from the left navigation and open the classic settings page by clicking "Classic Settings Page"
    c. Scroll down to "Custom Script" section
    Under Custom Script section, Set "Allow users to run custom script on personal site" and "Allow users to run custom script on self-service created sites" options.
    d. Click on "OK" to save your changes.

    NB: This enables custom scripting in SharePoint Online. However, this change may take up to 24 hours or more to reflect. Check if the change has been processed in the SharePoint Admin Center.
    e. Delete the existing aspx file from SharePoint and upload the aspx file using the SharePoint Upload button (i.e. do not use drag and drop).
  4. Allow use of scripts in SharePoint Online using PowerShell (immediate effect)
    SPO PowerShell
    Connect-SPOService https://<yourinstance>

    Set-SPOsite https://<yourinstance><yoursite> -DenyAddAndCustomizePages 0
    PnP PowerShell
    Connect-PnPOnline -PnPManagementShell -Url https://<yourinstance>
    Set-PnPSite https://<yourinstance><yoursite> -NoScriptSite $false

    Remove the existing aspx page and then upload the aspx file again
    Note: it will not work if you only have "member" permissions on the site
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Article is closed for comments.
Powered by Zendesk