c# - Using similar Controllers in areas in Asp.Net Mvc -


i'm developing sport based web site asp.net mvc 4.

the site being developed show 1 sport data @ time.

the sports have similar datas in common have different datas.

site supports many sports that’s why, not want use common controllers/views seperating sports if statements.

i tried one:

i have created area each sport. described controllers in area related sport.

for example, in route, name of controller , area stated, firstly searched in area, if not there, searched in default(/controllers).

because controllers share same names, mvc defaultcontrollerfactory throws "ambiguous controller name exception". first i’m searching area, if cannot found i’m searching in default writing own controller factory. can reach project aid of link

in case, biggest deficiency is; without indicating namespace in route making same thing in views. search view in area, if not found search in default. because project theme-supported, use own themable razor view engine, not default razor view engine. can reached aid of 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 object of areaviewlocationformats of razorviewengine regardless of fact state area in route, searches viewlocationformats instead of areaviewlocationformats if not state namespace.

in case, how should separate sports?

what have done in similar scenario creating base generic controller this:

public abstract class basecontroller<tmodel> : controller tmodel : class, new() {    // controller actions shared controllers inherit form one... } 

and, controllers this:

public class tenniscontroller : basecontroller<tennis> { } 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -