CSS and JS files not found when Provider Hosted App in hosted on SharePoint Online RRS feed

  • Question

  • Hi,

    In my my SharePoint provider hosted app, all styles are working fine, i.e. CSS and JS files are loaded correctly but when I debug/deploy it to SharePoint online, most of the CSS and JS files are not loaded, returns 404 not found error, the reason why all my page styles and functionalities are malfunctioning. Few of them are loading. I have no idea why this is happening. Please help me to resolve the issue.

    Edit: sorry I forgot to mention, this app is developed by Asp.Net MVC 5 Razor.

    Layout Page:

        <link href="~/Content/themes/base/jquery-ui.css" rel="stylesheet" />
        <script src="~/Scripts/jquery-ui-1.12.1.js"></script>
        <link href="~/Content/themes/base/datepicker.css" rel="stylesheet" />
        <link href="~/Content/themes/base/jquery.ui.core.css" rel="stylesheet" />
        <link href="~/Content/themes/base/jquery.ui.datepicker.css" rel="stylesheet" />
        <link href="~/Content/themes/base/jquery-ui.min.css" rel="stylesheet" />
        <link href="~/Content/themes/base/jquery.ui.theme.css" rel="stylesheet" />
        <script src="~/Scripts/jquery.validate.js"></script>
        <script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
        <script src="~/Scripts/Common/DatePickerReady.js"></script>
        @RenderSection("scripts", required: false)
        @RenderSection("Styles", false)

    Other Razor Pages Script Section:

                <script src="~/Scripts/jquery-3.3.1.min.js"></script>
                <script src="~/Scripts/jquery-ui-1.12.1.min.js"></script>
                <link rel="stylesheet" href="//">
                <script src="~/Scripts/Custom_App_Script.js"></script>
                <link href="~/Content/Bootstrap.min.css" rel="stylesheet" />

    Bundle Config file:

    bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                // Use the development version of Modernizr to develop with and learn from. Then, when you're
                // ready for production, use the build tool at to pick only the tests you need.
                bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
                          "~/Scripts/bootstrap-datepicker.js",    // ** NEW for Bootstrap Datepicker
                bundles.Add(new ScriptBundle("~/bundles/spcontext").Include(
                bundles.Add(new StyleBundle("~/CSSBundle").Include(
                          "~/Content/bootstrap-datepicker.css",  // ** NEW for Bootstrap Datepicker

    Saturday, June 9, 2018 6:35 PM

All replies

  • Hi,

    If you want to reference JavaScript file instead of bundle, try with below solution.

    <script src="@Url.Content("~/Scripts/yourjsfile.js")"></script>

    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />

    While this is more related to MVC question, if you need future help, I would suggest you post in below MVC forum.

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge.

    Thanks for your understanding.

    Best Regards,


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Monday, June 11, 2018 8:54 AM
  • Hi Lee,

    Thanks for your response. I have tried your suggestions but no luck. I have already posted it to asp forum.

    Tuesday, June 12, 2018 4:29 AM