I´m using mvc futures 2 with WebApiEnabled for XML and JSON support. But due to cross domain issues with jQuery $.ajax I´m lookin in to JSONP.
Is there a simple way to extend futures rest function for JSONP or should I do something else.
Do anyone have some hints on this 开发者_高级运维subject ?
The REST for ASP.NET MVC SDK contains a Word file explaining how you could extend it by adding a custom format:
ASP .NET MVC provides capability to return HTML. MVC REST adds out of the box support to return the two most popular formats for programmatic access on the web: XML and JSON. In addition, you can also handle additional formats. This section shows how you can add support for a custom format such as Atom using the provided extensibility. The process involves creating a custom Format Handler, and registering it to handle requests, responses, or both. The steps specific to enabling custom formats are described below:
- Create a custom format handler that may implement either or both of the interfaces IRequestFormatHandler and IResponseFormatHandler.
- Register the custom format handler in global.asax in Application_Start
In the included MovieApp
sample you will find an implementation for AtomFormatHandler
which you could use as a base for adding the JSONP functionality. I've also written a JsonpResult which you may take a look at.
精彩评论