我有几个REST风格的端点就像这样:WCF 3.5 - 删除SVC扩展 - 特殊
System.Security.Role.svc
System.Security.User.svc
etc.
这意味着是一个命名空间,以便REST风格的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'结尾。