How to fix the "File not found error" when embedding aspx file in a Embed webpart on a SharePoint online site

Vaibhav Gupta 0 Reputation points
2023-07-25T12:08:06.72+00:00

I am trying to embed a static SharePoint page (.aspx file) using the Embed webpart on a SharePoint online site. The file is added to the Share Documents directory of the same site.

The end goal is to host a static website inside an iFrame on the SharePoint site. This static website will have some HTML pages (with the extension changed to .aspx), images, CSS, and JS. I have achieved this goal in my previous organization on a Classic SharePoint site using the Page Viewer webpart.

However, my current organization is using modern SharePoint site and I want to achieve the same goal on the modern site. After referring to a few of the articles over the internet, I saw that the custom scripts need to be enabled for the site where I want to embed the aspx files. On my request the IT team has enabled the custom scripts, but still no luck in displaying the pages. The site is still showing the "File not found" error.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
11,191 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Q&A Assist
    2023-07-25T12:08:06.72+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    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:

    1. 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.
    2. 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.
    3. 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.
    4. 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:

    0 comments No comments

  2. RaytheonXie_MSFT 38,876 Reputation points Microsoft Vendor
    2023-07-26T07:24:00.75+00:00

    Hi @Vaibhav Gupta

    Script Editor webpart is not available in SharePoint modern page now. You can check the details from following document

    https://support.microsoft.com/en-us/office/where-are-the-content-editor-and-script-editor-web-parts-in-sharepoint-ed6cc9ce-8b2a-480c-a655-1b9d7615cdbd

    If you want to ininject custom JS/CSS on only one modern page in site, I will suggest you to use the react-script-editor.

    https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-script-editor

    Here is the link for steps to deploy your spfx

    https://learn.microsoft.com/en-us/sharepoint/dev/spfx/sharepoint-framework-overview


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.