I'm developing a sport based web site with Asp.Net Mvc 4.
The site is being developed to show just one sport data at a time.
The sports have similar datas in common but also they have different datas.
Site supports many sports that’s why, I do not want to use common controllers/views by seperating sports with if statements.
I tried this one:
I have created an area for each sport. I described the controllers in area which are related to that sport.
For example, in Route, name of the controller and area will be stated, firstly it will be searched in area, if it is not there, it will be searched in default(/Controllers).
Because the controllers share the same names, Mvc DefaultControllerfactory throws "Ambiguous Controller Name Exception". First I’m searching area, if it cannot be found then I’m searching in default by writing my own Controller factory. You can reach the project by the aid of the this link
In this case, my biggest deficiency is; without indicating namespace in route making the same thing in views. So it will search view in area, if it will not be found then it will search in default. Because the project is theme-supported, I use my own themable razor view engine, not default razor view engine. It can be reached by the aid of this link
base.AreaViewLocationFormats = new[]
{
_themeService.Current.BasePath + "/Views/Areas/{2}/{1}/{0}.cshtml",
_themeService.Current.BasePath + "/Views/{1}/{0}.cshtml",
_themeService.Current.BasePath + "/Views/Shared/{0}.cshtml","~/Themes/Default/Views/{1}/{0}.cshtml"
};
I updated the object of AreaViewLocationFormats of RazorViewEngine like this but regardless of the fact that I state area in route, it searches ViewLocationFormats instead of AreaViewLocationFormats if I do not state namespace.
In this case, how should I separate sports?