I created an MVC app using VS Express for web. It it will only use the default built in CSS file that VS Express comes with.
Example: If I modify the bootstrap.css file (change jumbotron color), and run locally from VS, the changes are apparent, however when i web deploy, none of those changes are apparent. I also noticed when I modify the web.config file to Debug=false, the CSS changes I've made are not apparent when I run it locally from VS (and on web deploy).
CSS is still being applied, however any changes I make are not applied. The site shows the old default jumbotron color. If I change debug=true in the web.config then the jumbotron shows my updated color. When I web deploy my site none of the CSS changes are applied, it still uses the default CSS file, I even checked bootstrap.css on the server and it shows the updated jumbotron color, but the jumbotron is still the default color on the web?? Super confusing.
I have done a lot of reading, tried adding the following to my web.config:
<remove name="BundleModule" />
<add name="BundleModule" type="System.Web.Optimization.BundleModule" />
but that doesnt fix it. I tried removing .css from my file names, this fixed the problem when I run it locally from VS using debug=false, however when I publish the website the site shows no CSS styles at all. It is not a caching issue. It is something to do with bundling and debug=false, but I do not know what. I am still quite new to web/MVC development. I've updated my web.optimization and microsoft.aspnet, etc with NuGet.
I am having a really hard time with this, if anyone has a suggestion and it works I will be very happy! There are lots of posts about this on Stack Overflow but none of the suggestions have worked for me yet.
This is my bundle.config.cs:
using System.Web;
using System.Web.Optimization;
namespace HFHYYC
{
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate*"));
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/respond.js"));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/site.css"));
}
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…