Rob pinged me today asking about how to respond to requests using different formats based on the extension in the URL. More specifically, he?d like to respond with HTML if there is no file extension, but with JSON if the URL ended with .json etc... /home/index ?> HTML /home/index.json ?> JSON The first thing I wanted to tackle was writing a custom action invoker that would decide based on what?s in the route data, how to format the response. This would allow the developer to simply return an object (the model) from an action method and the invoker would look for the format in the route data and figure out what format to send. So I wrote a custom action invoker: public class FormatHandlingActionInvoker : ControllerActionInvoker { protected...(read more) ...
Go to the complete details ...