开发者

WCF 3.5 - Remove SVC Extension - Special Case

I have several RESTful endpoints like such:

System.Security.Role.svc
System.Security.User.svc
etc.

This is meant to be a namespace so our RESTful URL's would look like:

/rest/{class namespace}/{actions}

I have tried a few examples to get the SVC extension removed when my endpoint has multiple periods in it, however, nothing seems to work.

I have tested with the WCF REST Contrib package (http://wcfrestcontrib.codeplex.com/), this example (http://www.west-wind.com/weblog/posts/570695.aspx), and another StackOverflow post (How to remove the ".svc" extension in RESTful WCF service?).

This works great when my endpoint is something like this:

Echo.svc

It wil开发者_JAVA技巧l properly remove the SVC extension.

Any ideas on how to handle endpoints with multiple periods in the endpoint name?

EDIT: After some further testing, I found out that it is failing because whenever you do:

string path = HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath;

If the endpoint contains multiple periods, it strips off everything after the endpoint causing all of the standard IHttpModule's to fail.

Example:

If I call http://localhost/services/Echo/test, my relative app file path has a returned value of:

~/echo/test

However, if I make a call as http://localhost/services/System.Security.User/test, then my relative app file path has a returned value of:

~/system.security.user

I am missing the '/test' on the end in that situation.


Have you tried this solution - How to remove the ".svc" extension in RESTful WCF service?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜