开发者

WCF + Wildcard Mapping + IIS6 = 404s on Every Method!

I am receiving 404s when executing a WCF method on IIS6 when wildcard mapping is enabled.

You can all reproduce this by creating a new WCF Service in VS2008 (new Project > WCF Service Application). Browse to the dummy method ('GetData')... you will notice it returns 400... that's fine because it shows it's still forwarding to WCF.

However: if you enable wildcard mapping in IIS6 you will now get a 404, meaning WCF is no longer intercepting the request.

My code is as follows:

[ServiceContract]
public interface IRest {
    [OperationContract]
    [WebGet(UriTemplate = "/test")]
    int Test();
}

With the following web.config:

<system.serviceModel>
  <behaviors>
    <endpointBehaviors>
      <behavior na开发者_开发知识库me="ServiceX.RestBehavior">
        <webHttp />
      </behavior>
    </endpointBehaviors>
    <serviceBehaviors>
      <behavior name="ServiceX.RestBehavior">
        <serviceMetadata httpGetEnabled="false" />
        <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>

  <serviceHostingEnvironment aspNetCompatibilityEnabled="false" />

  <services>
    <service behaviorConfiguration="ServiceX.RestBehavior"
      name="ServiceX.Rest">
      <endpoint address="" behaviorConfiguration="ServiceX.RestBehavior"
        binding="webHttpBinding" contract="ServiceX.IRest" />
    </service>
  </services>
</system.serviceModel>

All works fine without wildcard mapping; I can browse to '/services/rest.svc/test' and I'll receive the expected result.

However, as soon as I enable wildcard mapping (.* > C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll), then I start receiving 404s when I attempt to access a method (although I can still view '/services/rest.svc').

I've exhausted Google and StackOverflow :(


I just had the same problem with a WCF service running on IIS6.

I could browse the service on http://someurl/service.svc, but I would get a 404 when hitting a method on the service such as http://someurl/service.svc/somemethod.

The fix, in my case, was easy. The .svc file type was configured in IIS to be handled by C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll, but my service was running in a ASP.NET v4.0 apppool, so I simply pointed the .svc file type to be handled by C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜