ASP.NET MVC 2 JSONP 与 MVC Futures

发布于 2024-08-31 03:29:17 字数 169 浏览 0 评论 0原文

我使用 mvc futures 2 和 WebApiEnabled 来支持 XML 和 JSON。但由于 jQuery $.ajax 的跨域问题,我正在寻找 JSONP。

有没有一种简单的方法来扩展 JSONP 的 future 休息功能,或者我应该做其他事情。

有人对这个主题有一些提示吗?

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ゝ杯具 2024-09-07 03:29:17

REST for ASP.NET MVC SDK 包含一个 Word 文件,解释如何通过添加自定义格式来扩展它:

ASP .NET MVC 提供了以下功能:
返回 HTML。 MVC REST 添加了
盒子支持返回最多两个
程序化的流行格式
Web 访问:XML 和 JSON。在
另外,你还可以处理
附加格式。本节显示
如何添加对自定义的支持
使用提供的格式,例如 Atom
可扩展性。该过程涉及
创建自定义格式处理程序,以及
注册它来处理请求,
响应,或两者兼而有之。具体步骤
启用自定义格式是
描述如下:

  1. 创建一个自定义格式处理程序,可以实现其中一个或两个
    接口 IRequestFormatHandler 和
    IResponseFormatHandler。
  2. 在 Application_Start 的 global.asax 中注册自定义格式处理程序

在包含的 MovieApp 示例中,您将找到 AtomFormatHandler 的实现,您可以将其用作添加 JSONP 功能的基础。我还写了一个 JsonpResult你可以看一下。

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:

  1. Create a custom format handler that may implement either or both of the
    interfaces IRequestFormatHandler and
    IResponseFormatHandler.
  2. 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文