.NET 3.5 中的 REST 友好 WCF 端点
我想通过避免使用 .svc 来使用我的 WCF 服务端点创建 REST 友好的 URL。我知道我可以通过使用 IIS 重写模块附加 .svc 来完成此任务。
还有其他人知道更好的方法吗?
请注意,我仅限于.NET 3.5,无法使用.NET 4.0(因此无法在.NET 4.0中使用System.Web.Routing)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不幸的是,如果不使用重写模块,目前还没有办法做到这一点。 MS 的一个团队正在开发 WCF REST 入门工具包,可在此处 谁在考虑实现此功能。
在我今年早些时候就该主题进行的 Microsoft DevDays 演示中,Ron Jacobs 确认只有 Framework 4.0 及以上版本才提供执行此操作的功能,并且对于重写模块以下的任何内容来说,这是执行此操作的唯一方法。
Unfortunately without using the Rewrite module therre is currently no way of doing this. There is a team at MS working on the WCF REST Starter Kit available here who where looking at implementing this functionality.
During a Microsoft DevDays presentation I did earlier this year on the topic, a got confirmation from Ron Jacobs that the ability to do this will only be available in Framework 4.0 onwards, and for anything below the rewrite module is the only way to do this.
您可以将 ISAPI 重写模块“插入”到 IIS 中来为您执行此操作,例如 Ionic:
http:// /www.codeplex.com/IIRF
您还可以早在 .NET 1.1 中编写自己的 HTTP 重写引擎 - 尽管这需要有一个可以映射为使用 ASP.NET 引擎的文件扩展名仅在 IIS 将请求传递到 .NET 后重写 - 但它可以是您选择的任何扩展名。
对于你的问题,ISAPI重写模块是最好的解决方案。
You can "plug in" an ISAPI rewrite module to IIS that would do this for you, such as Ionic:
http://www.codeplex.com/IIRF
You can also write your own HTTP rewrite engine as early as .NET 1.1 - although that would need to have a file extension that could be mapped to use the ASP.NET engine as it only rewrites after IIS passes the request to .NET - but it could be any extension you choose.
For your question, the ISAPI rewrite module is the best solution.
WCF Contrib 库(我还没有使用过)声称有能力做到这一点。
The WCF Contrib library (which I have not used yet) claims to have the ability to do this.