Simple URL routes in WCF Rest 4.0 without trailing slash

后端 未结 7 1510
太阳男子
太阳男子 2021-02-01 20:27

I have a WCF REST 4.0 project based on the the WCF REST Service Template 40(CS). I\'d like to expose simple service endpoint URLs without trailing slashes. For example:

7条回答
  •  半阙折子戏
    2021-02-01 20:54

    Older question but here's how I solved the problem with a WCF4 REST service (using the RouteTable in Global.asax to add ServiceRoutes). IIS7 is configured so that by the time the service is invoked I have an empty relative path so the handling method's UriTemplate is empty like Will's Car example. I used a rewrite rule in the service's web.config file to add a "/" if needed. It always matches the path then checks the original URI ({REQUEST_URI}) to see if it contains a path without a trailing "/".

        
            
                
                
                    
                    
                        
                    
                    
                
            
        
    

提交回复
热议问题