Asp.Net mvc with ServiceSTack Mvc powerpack
There is a row in AppHost:
ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
So this is my code
public class BaseController<T>:Controller
{
protected IRepository<T> Repository {get;set;}
public ActionResult Detail(T t){}
}
public class CarController:BaseController<Car>
{
}
I will use this code in App.Host
container.Register<IRepository<Car>>(c => new CarRepository());
How can I AutoWire Repository ?
Only public properties or constructors get injected, so try make Repository public with:
Also if you are using the MVC PowerPack you may want to inherit from the ServiceStackController instead which gives you a lot of benefits, like using ServiceStack’s JSON serialization, have access to ServiceStack’s shared Cache and Session providers as well as be able to share ServiceStack Authentication/Authorization features on both MVC Controllers and ServiceStack web services (if you’re using any).