A. Murray
A. Murray

Reputation: 2801

ASP.NET MVC 3 Return JsonResult and XML String

I have 2 screens on my front end 1 of which uses JSON to render itself and the other uses XML transformed by an XSLT to render a table. Both screens are tabs which the user can switch between quickly for reference purposes, therefore both pieces of data are required at the same time.

The two pieces of data are returned in the same COM interop call, as XML - 1 of which is parsed onto POCOs (and returned as Json) the other I want to return as straight XML. I don't want to have to call the COM interop method twice as it's a fairly beefy load. Ideally, I'd like to pass back the Json and the XML in the same controller method call to save me having to call the COM interop method again.

Is there any way I can return my XML and JsonResult from the same controller method?

Also, I currently use jQuery to make the call to the controller method, the data param contains the Json result, how would I be able to get a handle on the XML I would pass back as well?

Upvotes: 0

Views: 591

Answers (1)

Mark Redman
Mark Redman

Reputation: 24535

Can you not add a string property (poco.AsXML) to the POCO and set that as the xml? which gets passed back in the JSON object?

(if I have understood the question)

Upvotes: 1

Related Questions