Carlos Mendes - 38 - Nov 6, 2014

What’s the best way to render the HTML output of a service inside a Razor page?

I’m looking for something similar to MVC’s RenderAction.

Thanks in advance

Carlos Mendes:

Hi Demis, in this case they’re rendering a ViewPage.

I need to resolve a service instead and render its html output.

That was an example of rendering a view page? Can I get you to ask a question on StackOverflow detailing what views/src you have and what you’re trying to do?

There’s an example here: http://stackoverflow.com/a/22515261/85785

Carlos Mendes:

I’m sorry if I wasn’t clear. 

There is a question in SO already about how to render the output of a service inside a view:

http://stackoverflow.com/questions/15028447/servicestack-razor-html-renderaction-equivalent

Can you answer there? Or should I create a new one?

I’ll work on creating a test for this, but it looks like you should just be able to call a service and pass the response in, e.g: 
@{ var response = svc.Get(new Request()); }
@Html.Partial(“View”, response)

Carlos Mendes:

Thank you
__________

Hi Carlos I’ve added a new RenderToAction method to v4.0.34 that’s now on https://github.com/ServiceStack/ServiceStack/wiki/MyGet and added some examples to the StackOverflow answer, e.g: http://stackoverflow.com/a/26823819/85785

Carlos Mendes:

Thank you Demis!
__________