3

I have a service hosted using wsHttpBinding on an address (the host base address is http://localhost/MyService).

In my contract (IMyService), I have:

    [OperationContract]
    [WebInvoke(
        Method = "GET",
        UriTemplate = "/")]
    Stream GetRootPage();

If I run my service and browse to http://localhost/MyService/, it works fine. If I browse to http://localhost/MyService, I am greeted with a default WCF page indicating that the metadata publishing service is not enabled for this service.

I have tried various combinations of UriTemplate:

  • UriTemplate = ""
  • UriTemplate = "/"
  • UriTemplate = "*"

In combination with the service base address:

All of them yield the same behavior. At some point previously, I could have sworn this was working, though I think I may have been using a subpath in the UriTemplate. I know that if I have a UriTemplate of "/abc/123/", I can browse to /abc/123 (without the trailing slash) because WCF actually issues an HTTP 307 redirect automatically.

I am using .NET 4.0.

Travis
  • 2,654
  • 4
  • 26
  • 46

2 Answers2

3

I figured out how to do this:

Ensure that the default WSDL generation is disabled (or at least not using the default URL):

<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />

Ensure that the help URL is disabled:

<serviceDebug httpHelpPageEnabled="false" httpsHelpPageEnabled="false" />
Travis
  • 2,654
  • 4
  • 26
  • 46
0

I think your question is already answered in: Simple URL routes in WCF Rest 4.0 without trailing slash.

Can you verify that?

Community
  • 1
  • 1
kroonwijk
  • 8,340
  • 3
  • 31
  • 52
  • I saw that before, though looking at it more closely, I did not see the ServiceRoute code. My initial assumption was that the service hosted there was www.domain.com, and the UriTemplate used was "cars." Let me play around with my code a bit more. – Travis Sep 17 '11 at 00:11
  • Looking at this more, it does not answer my question. This is adding a route so that multiple services are essentially hosted at the same address. I am essentially just trying to host something on the root address (without the trailing slash) – Travis Sep 17 '11 at 22:06