title: How to implement a custom controller factory ASP.NET MVC
body: <p>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.</p>
  
  <p>a guy explain so less so i just do not understand how to implement. here is the post url
  <a href="https://stackoverflow.com/questions/848904/in-asp-net-mvc-is-it-possible-to-make-a-generic-controller?rq=1">In asp.net mvc is it possible to make a generic controller?</a></p>
  
  <h2>he said</h2>
  
  <p>You would like <code>/Product/Index</code> to trigger <code>MyController&lt;Product&gt;.Index()</code></p>
  
  <p>This can be accomplished by writing your own IControllerFactory and implementing the <code>CreateController</code> method like this:</p>
  
  <pre><code>public IController CreateController(RequestContext requestContext, string controllerName)
  {
      Type controllerType = Type.GetType("MyController").MakeGenericType(Type.GetType(controllerName));
      return Activator.CreateInstance(controllerType) as IController;
  }
  </code></pre>
  
  <p>need a bit more sample code. just do not understand where to define <code>CreateController</code> function. do i need to write this function in base controller ?</p>
  
  <p>when request comes like <code>/Product/Index</code> or <code>/Customer/Index</code> then how index method can be invoke in base controller?</p>
  
  <p>so looking for guidance for a newbie like me in MVC advance area. thanks</p>