简体   繁体   English

在Visual Studio 2012调试期间ASP.Net MVC4上未显示CSS

[英]CSS not showing on ASP.Net MVC4 during Visual Studio 2012 Debug

When I debug my site the CSS does not show. 当我调试网站时,CSS不显示。 I get an Error 500 on the Site.css when I inspect it in Firefox. 在Firefox中检查它时,Site.css上显示错误500。

My _Layout.cshtml is set to use the css files. 我的_Layout.cshtml设置为使用css文件。

@Styles.Render("~/Content/css")

I did verify the Site.css file is in the correct folder and I can open it directly using Notepad. 我确实确认Site.css文件在正确的文件夹中,并且可以使用记事本直接打开它。

I have looked at BundleConfig.cs and I see where it's bundled with the other files. 我查看了BundleConfig.cs,然后看到它与其他文件捆绑在一起的位置。

bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));
bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
                    "~/Content/themes/base/jquery.ui.core.css",
                    "~/Content/themes/base/jquery.ui.resizable.css",
                    "~/Content/themes/base/jquery.ui.selectable.css",
                    "~/Content/themes/base/jquery.ui.accordion.css",
                    "~/Content/themes/base/jquery.ui.autocomplete.css",
                    "~/Content/themes/base/jquery.ui.button.css",
                    "~/Content/themes/base/jquery.ui.dialog.css",
                    "~/Content/themes/base/jquery.ui.slider.css",
                    "~/Content/themes/base/jquery.ui.tabs.css",
                    "~/Content/themes/base/jquery.ui.datepicker.css",
                    "~/Content/themes/base/jquery.ui.progressbar.css",
                    "~/Content/themes/base/jquery.ui.theme.css"));
    }

the really odd part is I do have this setup on IIS7.5 and the css works, but the background image does not. 真正奇怪的部分是我确实在IIS7.5上进行了此设置,并且CSS可以工作,但是背景图像却没有。 We are getting error 500 on it also. 我们也收到错误500。 The IIS_Users does have the rights to access those files. IIS_Users确实有权访问这些文件。

The last problem is that any images are not showing on the site. 最后一个问题是网站上没有显示任何图像。 On the css the background is set like 在css上,背景设置为

background: url("../Images/heroAccent.png") no-repeat; 背景:url(“ ../ Images / heroAccent.png”)不重复;

The Images directory is under the same directory as Views/Models/Controllers etc. Images目录与Views / Models / Controllers等位于同一目录下。

These errors raise for mvc bundling features in css having image path absolute. 这些错误会导致具有图像路径绝对值的css中的mvc捆绑功能。 here are two ways resolved the error 这是解决错误的两种方法

  1. off bundling (using EnableOptimization=false) 关闭捆绑(使用EnableOptimization = false)
  2. Correct image path with doing root path relative 通过做相对于根路径来校正图像路径

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

相关问题 图像未在ASP.net visual studio 2012中显示 - Image not showing in ASP.net visual studio 2012 如何在 Visual Studio 2019 中调试 ASP.Net MVC - How to debug ASP.Net MVC in Visual Studio 2019 使用Visual Studio 2010在ASP.NET MVC4教程的app_data中未显示数据库文件 - database file not showing in app_data in asp.net mvc4 tutorial using visual studios 2010 MSBuild编译ASP.NET MVC4应用程序-使用Visual Studio 2015设计 - MSBuild compiling ASP.NET MVC4 application - designed using Visual Studio 2015 使用IIS7无法对asp.net进行Visual Studio 2012调试 - visual studio 2012 debug for asp.net not working using IIS7 JavaScriptSerializer期间ASP.NET MVC4中的MaxJsonLength异常 - MaxJsonLength exception in ASP.NET MVC4 during JavaScriptSerializer 如何在Visual Studio 2012上使用ASP.NET(包含MVC)C#配置或设置Log4Net - How to configure or setup Log4Net with ASP.NET ( included MVC) C# on Visual Studio 2012 ~ ~ <a>点击时</a>改变颜色<a>(asp.net mvc 4 visual studio 2012)?</a> - Change color <a> when click (asp.net mvc 4 visual studio 2012)? 哪个实体框架在 Visual Studio 2012 和 ASP.NET MVC 4 和 Windows 7 中使用? - Which Entity Framework is used in Visual Studio 2012 with ASP.NET MVC 4 with Windows 7? 如何在Visual Studio 2012中为ASP.NET MVC 4配置Microsoft.Owin.Security.Google? - How to configure Microsoft.Owin.Security.Google for ASP.NET MVC 4 in Visual Studio 2012?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM