Bundled css link gets a 404 error
It seems that you have missed the step in which you apply your configuration by calling RegisterBundles
in Application_Start
:
protected void Application_Start()
{
...
BundleConfig.RegisterBundles(BundleTable.Bundles);
...
}
Usually in cases where the BundleConfig
class is already there (either as a part of the project template or created by NuGet package during the installation) this call is also already present - this is why many tutorials are implicit about it.
You should also be aware that the BundleConfig
class is there for separation of concerns and in order to keep the Application_Start
clean. In simple cases nothing prevents you from registering bundles directly in Application_Start
:
protected void Application_Start()
{
...
BundleTable.Bundles.Add(new StyleBundle("~/bundles/styles/cvi").Include("~/mainstyles.css"));
...
}
Found this question via google results, but the problem in my case was Windows 2008 needed this in web.config
to work when compilation debug=false.
<system.webServer>
<modules>
<add name="BundleModule" type="System.Web.Optimization.BundleModule" />
</modules>
</system.webServer>
It worked fine on Win7 dev machine without this.
I had the same problem that my script bundle suddenly responded with 404. I a solution similar to @fiat answer that I found on this blogpost.
The solution was to remove and add the BundleModule
in the modules part section of the system.webServer
section.
<modules runAllManagedModulesForAllRequests="true">
<remove name="BundleModule" />
<add name="BundleModule" type="System.Web.Optimization.BundleModule" />
</modules>