I am trying to get bundling to work in ASP.NET MVC 4. I am getting a 404 error from the link generated for the bundled CSS. I have done the following:
Ins
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"));
...
}