MVC Integration

I’m currently trying to integrate ServiceStack 5.1.1 into an ASP MVC project.

When I am trying to access the service class I’m getting the following:

Get is unresolved. I’m sure this is a simple thing but what am I missing ?

Obviously I can make this work by using hello.Any but this doesn’t seem quite right ?

You’re calling the Service class directly so you can only call methods that are declared on the class. This is a direct C# method call so I don’t understand the issue of calling existing methods since that’s all you can do.

Another way to invoke the Service is to use the Service Gateway, where if your MVC Contoller inherits the ServiceStackController you can call with:

var response = base.Gateway.Send(new MyRequest());

Using the Service Gateway has the benefit that your call-sites remain the same even if you later decide to move the Service you’re calling to a different Microservice, it will also execute any validation filters if your Service has any.

Sorry, I should have mentioned that I followed the instructions on the MVC Integration tutorial.

http://docs.servicestack.net/mvc-integration

This tutorial has a couple of bugs in it (e.g switching from MyService to HelloService) but unless I’m mistaken it implies that a Get call is possible, that is really all I was questioning was whether I had the right access point.

Thanks for the info, Ill look into the method you have suggested.

1 Like