views:

114

answers:

2

I need to send a big block of HTML in a Json object like this:

                JsonResult jsn =  Json(new Dictionary<string, object> { { "success", true }, 
            { "lastPID", posts[0].ID }, 
            { "content", "" } });
            return jsn;

For some reason I get this error when I put that html block into the content variable: Server cannot set content type after HTTP headers have been sent.

This doesn't happen if I return some random non-html content.

Is there any encoding that I need to do before I can send my big block of html?

What about the client end? How do I get back the data.

+1  A: 

If you need to send HTML, why not just send HTML rather than JSON?

Ian Oxley
Because I also need to send some other data 'lastPID' in the same result. It's very important that I send the lastPId.
Cyril Gupta
One way is to have a javascript function inside the send html that sets the id. If you render the hmtl this function can get called (ie by $(document).ready)
Malcolm Frexner
+1  A: 

Looks like this is your problem (and solution)

David Hedlund