I have created a servicestack MVC project, this I use as the main API for the database. because I want to access the models in my code I have also added a reference to this project in my MVC Views Project and Controllers project.
However I am having real problems when I run my project [ the web site project ] in that ServiceStack thinks it owns my solution, and takes over all request, and is then unable to resolve my routes.
I have added routes in the web projects global file, I have also tried adding these routes to the servicestack project, but still unable to resolve.
here is the error:
[ResolutionException: Required dependency of type uyr.print.controllers.Controllers.UsersController could not be resolved.]
Funq.Container.ThrowMissing(String serviceName) in C:\src\ServiceStack\src\ServiceStack\Funq\Container.cs:297
Funq.Container.GetEntry(String serviceName, Boolean throwIfMissing) in C:\src\ServiceStack\src\ServiceStack\Funq\Container.cs:275
Funq.Container.ResolveImpl(String name, Boolean throwIfMissing) in C:\src\ServiceStack\src\ServiceStack\Funq\Container.cs:112
Funq.Container.ResolveNamed(String name) in C:\src\ServiceStack\src\ServiceStack\Funq\Container.Overloads.cs:283
Funq.Container.Resolve() in C:\src\ServiceStack\src\ServiceStack\Funq\Container.Overloads.cs:230
lambda_method(Closure , Container ) +41
ServiceStack.ServiceHost.ContainerResolveCache.CreateInstance(Type type, Boolean tryResolve) in C:\src\ServiceStack\src\ServiceStack\ServiceHost\ContainerResolveCache.cs:62
ServiceStack.ServiceHost.ContainerResolveCache.CreateInstance(Type type) in C:\src\ServiceStack\src\ServiceStack\ServiceHost\ContainerResolveCache.cs:37
ServiceStack.Mvc.FunqControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) in C:\src\ServiceStack\src\ServiceStack.FluentValidation.Mvc3\Mvc\FunqControllerFactory.cs:38
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +74
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +232
System.Web.Mvc.<>c__DisplayClass6.<BeginProcessRequest>b__2() +49
System.Web.Mvc.<>c__DisplayClassb`1.<ProcessInApplicationTrust>b__a() +13
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Func`1 func) +124
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +98
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +50
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8970356
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
If anyone can point me in the right direction here, it would be much appreciated.
thanks
in that ServiceStack thinks it owns my solution, and takes over all request, and is then unable to resolve my routes.
ServiceStack doesn't own anything you don't explicitly tell it to.
ServiceStack ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
This tells MVC to use ServiceStack built-in Funq IOC to resolve and auto-wire all MVC Controllers. Typically if you have ServiceStack + MVC running together in the same project you want to use the same IOC to resolve ServiceStack services and MVC Controller dependencies.
Uncomment that line if you don't want MVC Controllers to use ServiceStack's IOC.
In the Web.config you also tell ServiceStack exactly what path you want ServiceStack to handle.
These are the only 2 places where ServiceStack is configured to handle requests. If you don't have any of these configurations than the ServiceStack dlls are benign and doesn't have any effect on your project. i.e. There are no HTTP Modules registered that invasively attempts to hi-jack requests.
The only library here with that problem is MVC where it thinks it owns the whole solution, even after telling IIS to delegate all /api
requests to ServiceStack (with the Web.Config) you also need to tell MVC to explicitly ignore these routes with:
routes.IgnoreRoute("api/{*pathInfo}");
Otherwise it will try to handle them.