我有几个RESTful端点,如:
System.Security.Role.svc
System.Security.User.svc
etc.
这是一个名称空间,所以我们的RESTful URL看起来像:
/rest/{class namespace}/{actions}
我尝试了一些示例,当我的端点有多个句点时,会删除SVC扩展名,但似乎没有任何效果。
我已经使用WCF REST Contrib包(http://wcfrestcontrib.codeplex.com/),此示例(http://www.west-wind.com/weblog/posts/570695.aspx)和另一个StackOverflow帖子(How to remove the ".svc" extension in RESTful WCF service?)进行了测试。
当我的端点是这样的时候,这很有效:
Echo.svc
它将正确删除SVC扩展名。
关于如何处理端点名称中具有多个句点的端点的任何想法?
编辑: 经过一些进一步的测试后,我发现它失败了,因为每当你这样做:
string path = HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath;
如果端点包含多个句点,则会在端点导致所有标准IHttpModule失败后删除所有句点。
示例:
如果我拨打http://localhost/services/Echo/test,我的相对应用文件路径的返回值为:
~/echo/test
但是,如果我以http://localhost/services/System.Security.User/test拨打电话,那么我的相对应用文件路径的返回值为:
~/system.security.user
在那种情况下,我错过了'/ test'。