WCF 3.5 - Remove SVC Extension - Special Case

Posted by Brandon on Stack Overflow See other posts from Stack Overflow or by Brandon
Published on 2010-05-03T18:07:36Z Indexed on 2010/05/03 19:18 UTC
Read the original article Hit count: 497

Filed under:
|
|
|

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 (http://stackoverflow.com/questions/355165/how-to-remove-thie-svc-extension-in-restful-wcf-service).

This works great when my endpoint is something like this:

Echo.svc

It will 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.

© Stack Overflow or respective owner

Related posts about c#

Related posts about wcf