简体   繁体   English

我在IIS7中托管应用程序时未加载CSS和Javascript

[英]CSS and Javascripts are not loading when i host application in IIS7

I am trying to host asp.net application in IIS7. 我正在尝试在IIS7中托管asp.net应用程序。 I am using published version of application. 我正在使用应用程序的发布版本。 when i run it all css and javascripts are not loading. 当我运行它时,所有css和javascript均未加载。 the strange is when i run from visual studio it working fine. 奇怪的是,当我从Visual Studio运行时,它工作正常。

error in browser console like this : Failed to load resource: the server responded with a status of 404 (Not Found) 这样的浏览器控制台中的错误: Failed to load resource: the server responded with a status of 404 (Not Found)

I analyse the issue and come to know that css and js path is not correct. 经过分析,我发现CSS和JS路径不正确。 you can see in below image. 您可以在下图中看到。 it is http://localhost/css/bootstrap.css but it should be http://localhost/MICPA1/css/bootstrap.css 它是http://localhost/css/bootstrap.css但应该是http://localhost/MICPA1/css/bootstrap.css

浏览器控制台错误。

I have used bundle for css and js like MVC. 我已经为css和js像MVC使用了bundle。

bundles.Add(new StyleBundle("~/bundles/commonStyle").Include(
            "~/css/bootstrap.css",
            "~/css/style.css",
            "~/css/datepicker.css"
            ));

        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
            "~/Scripts/jquery.min.js"));

        bundles.Add(new ScriptBundle("~/bundles/commonJquery").Include(
            "~/Scripts/bootstrap.min.js",
            "~/Scripts/script.js"));

I also tried simple link tag but it is also not working. 我也尝试了简单的link标记,但也无法正常工作。

The problem is with the IIS,It is not serving Static Content, which you can set up as diplayed in the image 问题出在IIS上,它不提供静态内容,您可以将其设置为图像中显示的内容

在此处输入图片说明

if you have checked that and it still does not work then what you need to do is set the identity of the anonymous authentication to the Application Pool Identity if it is on specific user here is an image of where that is. 如果您已经检查了它并且仍然不起作用,那么您需要做的是将匿名身份验证的身份设置为“应用程序池身份”(如果它位于特定用户上),这是该位置的图像。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM