When embedding an .aspx file, sometimes SharePoint may generate the error "File not found". Here are some things you can try to fix the issue:
- Ensure that the path to the .aspx file is correct and valid. If the file is located in the Shared Documents directory, ensure that the path is correct and that the permissions are set correctly so that the file can be accessed.
- Check if the custom scripts feature is enabled. If you are using a modern SharePoint site, you may need to enable the custom script feature. This can be done in the SharePoint admin center or using PowerShell. If the feature is already enabled, try disabling and re-enabling it.
- Ensure that the permissions are set correctly. Sometimes, the "File not found" error can be caused by incorrect permissions on the file or the site. Ensure that the user or group has access to the file and the site.
- Try using the SharePoint Framework (SPFx) instead of the Embed web part. SPFx is a supported and standardized way of achieving similar solutions previously built using JavaScript embeddings. It provides more control over scripting capabilities in SharePoint Online and can be a direct replacement for Script Editor web parts used to insert HTML, JavaScript, or CSS customizations.
If none of the above solutions work, you may need to consider a different approach to achieve your goal of hosting a static website inside an iFrame on the SharePoint site.
References:
- "Trying to view a SharePoint .aspx page generates the error 'This page is not using a valid page layout'" https://learn.microsoft.com/en-us/sharepoint/troubleshoot/sites/page-not-use-valid-page-lauout
- "SharePoint Framework enterprise guidance" https://learn.microsoft.com/en-us/sharepoint/dev/spfx/enterprise-guidance