简体   繁体   中英

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

I am trying to host asp.net application in IIS7. I am using published version of application. when i run it all css and javascripts are not loading. the strange is when i run from visual studio it working fine.

error in browser console like this : 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. you can see in below image. it is http://localhost/css/bootstrap.css but it should be http://localhost/MICPA1/css/bootstrap.css

浏览器控制台错误。

I have used bundle for css and js like MVC.

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.

The problem is with the IIS,It is not serving Static Content, which you can set up as diplayed in the image

在此处输入图片说明

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.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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