none
Routing is not working for WCF service RRS feed

  • Question

  • I have a WCF service which has .svc tag and I want get rid of that.

    So, in my global file I added this code

                RouteTable.Routes.Add(
                    new ServiceRoute(
                        "account", new WebServiceHostFactory(),
                        typeof(v1.Account))); 

    When I try to access with .svc extension; this works. But if I call the url directly with "account" it doesn't work.

    This is how I have my Web.config defined:

     <service behaviorConfiguration="ServiceBehaviors" name="Service.v1.Account">
            <endpoint address="json" behaviorConfiguration="RestBehavior" binding="webHttpBinding" bindingConfiguration="webBinding" contract="Service.v1.Interfaces.IAccount" />

    Any help will be really appreciated.

    Thanks,

    Harsimrat

    Monday, October 28, 2013 9:46 PM

Answers

  • Hi,

    The "account" string within your ServiceRoute(...) is being appended to the root of your application to determine the route to your service.  So in order to fix this you can simply publish your service to the root of its own site, or make your RouteTable declaration look like this: 

    RouteTable.Routes.Add(new ServiceRoute("", new WebServiceHostFactory(), typeof(yourServiceType)));

    For more information, please try to refer to the following blog:
    http://jdscolam.blogspot.in/2011/01/wcf-rest-404-issue.html .

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by thukralz Tuesday, October 29, 2013 5:56 AM
    Tuesday, October 29, 2013 5:27 AM
    Moderator

All replies

  • Hi,

    The "account" string within your ServiceRoute(...) is being appended to the root of your application to determine the route to your service.  So in order to fix this you can simply publish your service to the root of its own site, or make your RouteTable declaration look like this: 

    RouteTable.Routes.Add(new ServiceRoute("", new WebServiceHostFactory(), typeof(yourServiceType)));

    For more information, please try to refer to the following blog:
    http://jdscolam.blogspot.in/2011/01/wcf-rest-404-issue.html .

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by thukralz Tuesday, October 29, 2013 5:56 AM
    Tuesday, October 29, 2013 5:27 AM
    Moderator
  • Thank you; that fixed it.

    Harsimrat

    Tuesday, October 29, 2013 5:56 AM