I am making an AJAX call (with jQuery) to retrieve a PartialView
. Along with the HTML I\'d like to send back a JSON representation of the object the View is dis
The same solution as Andrew, but maybe a bit more MVC'ish...
Create a new class which inherits from ViewPage. Override its Render method to render the page itself, and then stuff that into the output Andrew suggested. So that all the hacking occurs in the Render method, where it should happen.
Now each view that you create you change the line:
<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
with
<%@ Page Title="" Language="C#" Inherits="CustomViewPage" %>
I didn't check it myself, but guess it should work. If you want I can try and build it.