I'm able to add a ServiceRoute to my WCF .net 4.0 service with a .svc extension by following these posts:
However how can i remove the ".svc" extension?
My actual service file is called Catalog.svc
And after following those posts i'm able to access the same service using csw.svc
my Global.asa.cs:
protected void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
private void RegisterRoutes(RouteCollection routes)
{
routes.Add(new ServiceRoute("csw.svc", new WebServiceHostFactory(), typeof(CSW_ebRIM_WebService.Catalog)));
}
my Web.config:
...
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" >
<serviceActivations>
<add factory="System.ServiceModel.Activation.ServiceHostFactory"
relativeAddress="~/csw.svc"
service="CSW_ebRIM_WebService.Catalog"/>
</serviceActivations>
</serviceHostingEnvironment>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</modules>
<handlers>
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd"/>
</handlers>
</system.webServer>
However if I remove the .svc
extension from both the global and the web.config
I get and error saying:
The registered relativeAddress '~/csw' under section 'system.serviceModel/serviceHostingEnvironment/serviceActivations' in configuration file does not have an extension.
If i put back the .svc
extension on the web.config
and only remove it from the global I get:
Value cannot be null. Parameter name: contract
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: Value cannot be null. Parameter name: contract
What gives? How can I remove the .svc
extension?