How to remove the “.svc” extension in RESTful WCF service?

后端 未结 7 908
借酒劲吻你
借酒劲吻你 2020-11-29 17:41

In my knowledge, the RESTful WCF still has \".svc\" in its URL.

For example, if the service interface is like

[OperationContract]
[WebGet(UriTemplate         


        
7条回答
  •  悲&欢浪女
    2020-11-29 18:03

    Add this to your global.asax

    private void Application_BeginRequest(object sender, EventArgs e)
    {
        Context.RewritePath(System.Text.RegularExpressions.Regex.Replace(
                   Request.Path, "/rest/(.*)/", "/$1.svc/"));
    }
    

    This will replace /rest/Service1/arg1/arg2 by /Service1.svc/arg1/arg2

提交回复
热议问题