简体   繁体   中英

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 name="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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM