Reputation: 83
I'm using ASP.NET MVC 5 and attempting to resolve a few services using the example:
var authService = AppHostBase.Resolve<AuthService>();
authService.RequestContext = System.Web.HttpContext.Current.ToRequestContext();
var response = authService.Authenticate(new Auth
{
UserName = model.UserName,
Password = model.Password,
RememberMe = model.RememberMe
});
or I've also tried:
using (var helloService = AppHostBase.ResolveService<HelloService>())
{
ViewBag.GreetResult = helloService.Get(name).Result;
return View();
}
In the first case I needed the RequestContext
injected so I tried that approach and in the second case I was using the example which I understand has the RequestContext
automatically injected through Funq
.
ResolveService
could not be found when I tried the second approach and in the first approach RequestContext
is not a valid property. Am I missing something simple or has there been changes to the API?
Upvotes: 2
Views: 476
Reputation: 21511
The documentation does appear to be wrong for this as there is no longer a ResolveService<T>
on AppHostBase
. It needs to be updated due to changes in the Api.
You can do this in ServiceStack v4 with MVC:
var authService = HostContext.Resolve<AuthService>();
...
Upvotes: 1