简体   繁体   中英

WCF Methods Return 404 When Wildcard Mapping Is Enabled In IIS6

I have a REST WCF service defined 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').

Any ideas? I've exhausted Google and StackOverflow. No-one seems to be sharing this problem :(

EDIT: 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.

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

In the popup dialog where you specify the path for the wildcard mapping, there is check box for a setting called 'Verify that file exists'. This setting needs to be turned off.

If it is not turned off, you will get a 404 (page not found)

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