{"id":55,"date":"2011-04-11T14:50:00","date_gmt":"2011-04-11T14:50:00","guid":{"rendered":"https:\/\/wdev-blog.azurewebsites.net\/index.php\/2011\/04\/11\/routing-wcf-services-by-code\/"},"modified":"2011-04-11T14:50:00","modified_gmt":"2011-04-11T14:50:00","slug":"routing-wcf-services-by-code","status":"publish","type":"post","link":"http:\/\/panahy.nl\/index.php\/2011\/04\/11\/routing-wcf-services-by-code\/","title":{"rendered":"Routing WCF services by code"},"content":{"rendered":"<p>When you want to route the requests to specific WCF service deppending on the url, you can add routers on the Application_Start method of the Global.asax.cs. In the following example I want my ProductionService handle the service calls on the path starting with \/Production\/ and my PublicService handle the requests with a path starting with \/public\/demo\/<\/p>\n<div>\n<pre><span style=\"color: #0000FF;\">using<\/span><span style=\"color: #000000;\"> System;<br \/><\/span><span style=\"color: #0000FF;\">using<\/span><span style=\"color: #000000;\"> System.Web.Routing;<br \/><\/span><span style=\"color: #0000FF;\">using<\/span><span style=\"color: #000000;\"> System.ServiceModel.Activation;<br \/><br \/><\/span><span style=\"color: #0000FF;\">public<\/span><span style=\"color: #000000;\"> <\/span><span style=\"color: #0000FF;\">class<\/span><span style=\"color: #000000;\"> Global : System.Web.HttpApplication<br \/>{<br \/>    <\/span><span style=\"color: #0000FF;\">void<\/span><span style=\"color: #000000;\"> Application_Start(<\/span><span style=\"color: #0000FF;\">object<\/span><span style=\"color: #000000;\"> sender, EventArgs e)<br \/>    {<br \/>        <\/span><span style=\"color: #0000FF;\">#region<\/span><span style=\"color: #000000;\"> Register Routes<br \/>        var factory = <\/span><span style=\"color: #0000FF;\">new<\/span><span style=\"color: #000000;\"> WebServiceHostFactory();<br \/>        RouteTable.Routes.Add(<\/span><span style=\"color: #0000FF;\">new<\/span><span style=\"color: #000000;\"> ServiceRoute(<\/span><span style=\"color: #800000;\">\"Production\"<\/span><span style=\"color: #000000;\">, factory, <\/span><span style=\"color: #0000FF;\">typeof<\/span><span style=\"color: #000000;\">(ProductionService)));<br \/>        RouteTable.Routes.Add(<\/span><span style=\"color: #0000FF;\">new<\/span><span style=\"color: #000000;\"> ServiceRoute(<\/span><span style=\"color: #800000;\">\"Public\/demo\/\"<\/span><span style=\"color: #000000;\">, factory, <\/span><span style=\"color: #0000FF;\">typeof<\/span><span style=\"color: #000000;\">(PublicService)));<br \/>        <\/span><span style=\"color: #0000FF;\">#endregion<\/span><span style=\"color: #000000;\"><br \/>    }<\/span><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>When you want to route the requests to specific WCF service deppending on the url, you can add routers on the Application_Start method of the Global.asax.cs. In the following example I want my ProductionService handle the service calls on the path starting with \/Production\/ and my PublicService handle the requests with a path starting with &hellip; <a href=\"http:\/\/panahy.nl\/index.php\/2011\/04\/11\/routing-wcf-services-by-code\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Routing WCF services by code&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[49,20],"tags":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"post-thumbnail":false},"uagb_author_info":{"display_name":"Pouya Panahy","author_link":"http:\/\/panahy.nl\/index.php\/author\/pouya\/"},"uagb_comment_info":0,"uagb_excerpt":"When you want to route the requests to specific WCF service deppending on the url, you can add routers on the Application_Start method of the Global.asax.cs. In the following example I want my ProductionService handle the service calls on the path starting with \/Production\/ and my PublicService handle the requests with a path starting with&hellip;","_links":{"self":[{"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/posts\/55"}],"collection":[{"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/comments?post=55"}],"version-history":[{"count":0,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/posts\/55\/revisions"}],"wp:attachment":[{"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/media?parent=55"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/categories?post=55"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/tags?post=55"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}