This project is read-only.

HTML Processor HowTo

Topics: Web Api
Apr 2, 2011 at 10:45 PM

Hi, I'm not sure if if I understand the programming model completely just yet but I'm working on it! ;)

I'd like to have a non-js compatible form post operation that, when it posts to the REST end point, will automatically return HTML with a confirmation and a link to direct the user back to the home page. Lots more functionality when JS is enabled but this would allow me the backward compatible component I need. I figured that all I would need would be to create an HtmlProcessor similar to the PngProcessor but the HTTP stack already has one with no readfromstream or writetostream methods filled out.

So I think I missed something here. Is there an out of the box way to accomplish my task that I am missing?

Thanks in advance!


Apr 4, 2011 at 12:08 AM

Hi Axshon

The HtmlProcessor in the box derives from PlainTextFormatter. It expects the service to return a string of HTML which it will use as the body. It will then set the media type to "text/html". The reason it has no methods is because the base PlainTextFormatter implements them.

For what you are trying to do, you might take a look at this post from Steve Michelotti which shows how to use the ASP.NET Razor engine with a processor to return html. In that example the service does not return HTML as it returns a model which can be represented in multiple ways.

Alternatively you could create your own HTML processor which takes an object and turns into HTML, but does not use Razor to do so.