The style sheet '~/Scripts/app.js' is not located in any of the 'Style Sheet' folders designated in the web.config.

1 Answer 42 Views
ScriptManager and StyleSheetManager
Glenn
Top achievements
Rank 1
Iron
Iron
Glenn asked on 18 Nov 2024, 03:27 PM
We recently migrated our website over from a 2012 server to a 2022 server. Upon migration we're now receiving the following error:
Telerik.Web.UI.InsecureExternalStyleSheetException: The style sheet '~/Scripts/app.js' is not located in any of the 'Style Sheet' folders designated in the web.config.
Telerik.Web.UI.InsecureExternalStyleSheetException: Telerik.Web.UI.InsecureExternalStyleSheetException: The style sheet '~/Scripts/app.js' is not located in any of the 'Style Sheet' folders designated in the web.config.
  at Telerik.Web.UI.ExternalScriptHelper.ResolveSecurePath(String scriptRelativePath)

We then found this link: Telerik Forums Post

Following the instructions, we now have the following in our web.config file in <appSettings>:
<add key="Telerik.Web.UI.StyleSheetFolders" value="~/Scripts/; ~/styles/; ~/ReportViewer/js/; ~/kendo/js/;" />
We added multiple value's for the multiple different files that were being placed in the error messages.

We also ensured that our Master files for our different types of pages have been updated to match:

        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <telerik:RadScriptReference Path="~/Scripts/app.js" />
            </Scripts>
        </telerik:RadScriptManager>
        <telerik:RadStyleSheetManager runat="server" ID="RadStyleSheetManager1">
            <StyleSheets>
                <telerik:StyleSheetReference Path="~/Scripts/app.js" />
            </StyleSheets>
        </telerik:RadStyleSheetManager>
The errors are still being thrown. The pages work fine, but we don't want to be continuously being given these errors over and over again in Stackify.

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 21 Nov 2024, 12:16 PM

Hi Glenn,

For your convenience, I recreated your scenario and configure the StyleSheetManager to load the stylesheet files from the Styles folder. I also recorded my test in the attached video. You can use the project as a base to implement your scenario. Make sure that you are testing with the latest version.

More troubleshooting tips:

To resolve the Telerik.Web.UI.InsecureExternalStyleSheetException error, it appears that the issue stems from treating JavaScript files as stylesheets. Here are some steps to address this:

Remove JavaScript References from RadStyleSheetManager

  • Ensure that JavaScript files like app.js are not included in the <StyleSheets> section of the RadStyleSheetManager. JavaScript files should only be referenced in the RadScriptManager. Update your configuration as follows:

    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <telerik:RadScriptReference Path="~/Scripts/app.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <telerik:RadStyleSheetManager runat="server" ID="RadStyleSheetManager1">
        <StyleSheets>
            <!-- Add only CSS files here, not JavaScript files -->
        </StyleSheets>
    </telerik:RadStyleSheetManager>
    

Verify StyleSheetFolders Configuration

  • Ensure the Telerik.Web.UI.StyleSheetFolders key in the web.config is correctly pointing to directories containing only CSS files. If ~/Scripts/ primarily contains JavaScript files, remove it from the StyleSheetFolders setting.

Check for nested web.config files

  • The problem might be due to nested web.config files in the app. Make sure that the  <add key="Telerik.Web.UI.StyleSheetFolders" value="~/Scripts/; ~/styles/; ~/ReportViewer/js/; ~/kendo/js/;" /> setting is placed in the right web.config file and is taken into account.

Check for Misconfigurations

  • Double-check your web.config and ensure there are no other misconfigurations. Ensure all paths specified in the StyleSheetFolders setting are valid directories for stylesheets.

Additional Diagnostics

  • Since the errors persist, consider checking if there are any other references to JavaScript files in the RadStyleSheetManager or any other misconfigurations in your web.config.
  • Verify that the application pool is correctly configured for .NET 4.5 and is running in Integrated pipeline mode on the new server.
  • Ensure that the web application has the necessary permissions and that any compression settings, such as Dynamic IIS Compression, are configured correctly.

By ensuring that JavaScript files are referenced only in the RadScriptManager and not in the RadStyleSheetManager, you should be able to eliminate the InsecureExternalStyleSheetException errors. If the issue persists, please provide more details about any additional changes made during the migration or specific error messages for further assistance.

    Regards,
    Rumen
    Progress Telerik

    Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources
    Tags
    ScriptManager and StyleSheetManager
    Asked by
    Glenn
    Top achievements
    Rank 1
    Iron
    Iron
    Answers by
    Rumen
    Telerik team
    Share this question
    or