REST friendly WCF Endpoints in .NET 3.5
I wanted to create REST friendly URLs with my WCF service endpoints by avoiding the use of .svc. I know I can 开发者_开发百科accomplish this by using IIS rewrite module to append the .svc.
Does anyone else know of a better way to do this?
Please note that I am limited to .NET 3.5 and cannot use .NET 4.0 (so can’t use System.Web.Routing in .NET 4.0)
The WCF REST Starter Kit is no longer support and the suggested upgrade path uses the ASP.Net Web API which is part of ASP.Net MVC 4.0 and can be found here
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.
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.
The WCF Contrib library (which I have not used yet) claims to have the ability to do this.
精彩评论