I am creating a RESTful web service using ASP.NET MVC 4 web API. To return to the API, I return JSON, although as soon as I get everything that works correctly, content negotiation should work for XML and JSON by default.
Since I'm working on a truly RESTful resource oriented web service, my URI will point to the actual resources. I would like to take advantage of this by returning an HTML representation of the resource if Accepts: text/html comes in the request (for example, throws a link in the browser).
I would like to be able to use the content consistency of the MVC 4 Web API to insert a renderer for text / html using Razor templates. Are there any working examples for this?
Yes, this links the “regular” MVC pages and the web API. Basically, I would like to create a renderer that uses a convention-based approach to find and render Razor views just like a “regular” MVC. I can think of conventions based search logic. I'm just looking a) globally inserting text/html rendering into content matching and b) using the Razor mechanism manually to turn my model into HTML.
asp.net-web-api razor asp.net-mvc-4 content-negotiation
Mikejansen
source share