After uploading the files and clicking on the aspx file the file is downloaded. How can I avoid this?
Use one of the following methods.
- 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.
- Allow use of scripts in SharePoint Online
See https://www.sharepointdiary.com/2017/12/how-to-enable-custom-script-in-sharepoint-online.html “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).
- Use PowerShell to instantly change the configuration
Set-SPOsite https://<yourinstance>.sharepoint.com/sites/<yoursite> -DenyAddAndCustomizePages 0
Connect-PnPOnline -PnPManagementShell -Url https://<yourinstance>.sharepoint.com/
Set-PnPSite https://<yourinstance>.sharepoint.com/sites/<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