I’ve been happily returning JsonResult objects or partial ASP.NET views from my controllers in ASP.NET.
I would like to return a rendered partial view as a property in a JSON object. e.g.
requesting
/post/detail/1
would return
{"PostId": 1, "Html": "<p>some markup rendered from a partial to inject</p>" }
This would allow me to know the PostId when I am handling the response in JavaScript. Any tips on the best way to do this?
Here is some code that will work cause I needed to do this today. The original code is described here.
You can then use it to do RJS style json results
And the partial has a strongly typed view model