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:

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:

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 and added some examples to the StackOverflow answer, e.g:

Carlos Mendes:

Thank you Demis!