How would you do the resource bundling for asp.net mvc areas? Is this regulated by the ASP.NET MVC framework just like the AreaRegistration
for routes?
I could make a BundleConfig
class inside the area and call this from the global BundleConfig
inside the App_Start
folder but this doens't feel good to me.
I can't find any information on this subject. Any help our thoughts are appreciated.
I was hoping this was somehow more regulated - but after diving into the framework code the answer to this is negative.
What I decided to do is the following:
Solution Structure
RouteConfig.cs
internal static class RouteConfig
{
internal static void RegisterRoutes(AreaRegistrationContext context)
{
//add routes
}
}
BundleConfig.cs
internal static class BundleConfig
{
internal static void RegisterBundles(BundleCollection bundles)
{
//add bundles
}
}
AdminAreaRegistration.cs
public class AdminAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "Admin";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
RegisterRoutes(context);
RegisterBundles();
}
private void RegisterRoutes(AreaRegistrationContext context)
{
RouteConfig.RegisterRoutes(context);
}
private void RegisterBundles()
{
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
}