i am newbie in mvc area. so i am learning still and trying to learn lots of advance area in MVC. so i was reading a post about custom controller factory ASP.Net MVC.
a guy explain so less so i just do not understand how to implement. here is the post url In asp.net mvc is it possible to make a generic controller?
he said
You would like /Product/Index to trigger MyController<Product>.Index()
This can be accomplished by writing your own IControllerFactory and implementing the CreateController method like this:
public IController CreateController(RequestContext requestContext, string controllerName)
{
Type controllerType = Type.GetType("MyController").MakeGenericType(Type.GetType(controllerName));
return Activator.CreateInstance(controllerType) as IController;
}
need a bit more sample code. just do not understand where to define CreateController function. do i need to write this function in base controller ?
when request comes like /Product/Index or /Customer/Index then how index method can be invoke in base controller?
so looking for guidance for a newbie like me in MVC advance area. thanks