当我在IIS7中托管应用程序时,CSS和Javascripts没有加载 [英] CSS and Javascripts are not loading when i host application in IIS7

查看:184
本文介绍了当我在IIS7中托管应用程序时,CSS和Javascripts没有加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在IIS7中托管asp.net应用程序。我正在使用已发布的应用程序版本。当我运行它所有的CSS和javascripts没有加载。奇怪的是当我从visual studio运行它工作正常。



浏览器控制台中的错误如下:无法加载资源:服务器响应状态为404(未找到)



我分析了问题,并了解到css和js路径不正确。你可以在下面的图像中看到。它是 http://localhost/css/bootstrap.css 但它应该是 http://localhost/MICPA1/css/bootstrap.css





如果您已选中那它仍然不起作用然后您需要做的是
设置匿名身份验证的标识到应用程序池标识,如果它在特定用户上
这里是一个图像的位置。




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.

这篇关于当我在IIS7中托管应用程序时,CSS和Javascripts没有加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆