I'm trying to implement the concept of module in my ASP MVC application through Areas. I added a project named TimeSheet (I say it just as a reference) to the main solution and registered it as an Area, but without using the template generated Areas of Visual Studio, so writing the XXXAreaRegistration.cs (in the Module) by myself and using the AreaRegistration.RegisterAllAreas() in the Application_Start of the Main application.
Image of the Visual Studio solution
TimeSheetAreaRegistration.cs (in the module)
public class TimeSheetAreaRegistration : AreaRegistration
{
public override string AreaName
{
get { return "TimeSheet"; }
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"TimeSheet_Default",
"TS/{controller}/{action}/{id}",
new { controller = "Home", action = "get", id = UrlParameter.Optional },
new string[] { "TimeSheet.Controllers" }
);
}
}
Globa.asax (in main application
protected void Application_Start(object sender, EventArgs e)
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
//BundleConfig.RegisterBundles(BundleTable.Bundles);
// Nascondo la versione di MVC (X-AspNetMvc-Version)
MvcHandler.DisableMvcResponseHeader = true;
}
It works fine but for the fact that I cannot access the HttpContext of the main application that contains some informations I need. I researched a lot but without resolutive answer.
What am I missing ?
sadly I decided to roll back to Areas in the classical way. The research would be interesting, but with the bits and pieces I've found around I haven't been able to figure out a working approach in a reasonable time...which I'm lacking of at this moment.
Thanks