AngryHacker
AngryHacker

Reputation: 61646

Defining Routes in .NET 3.5 with WCF

I am trying to downgrade a .NET 4.0 app to 3.5 and I am having a hell of a time trying to define a route:

In 4.0, it looks like this:

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

It looks like .NET 3.5 does not have the ServiceRoute object. Am I missing something obvious here?

Upvotes: 2

Views: 1841

Answers (1)

carlosfigueira
carlosfigueira

Reputation: 87293

There's no support for WCF routes in 3.5 - this feature was introduced in 4.0. In 3.5 you have to live with the "ugly" .svc URIs for REST services.

So for the route example you mentioned, you'd add a file called something like UploaderService.svc with the following content:

<%@ ServiceHost
    Language="C#"
    Debug="true"
    Service="UploaderService" 
    Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>

Remember to use the fully-qualified name of UploaderService, if it's not on the "" namespace. And the file is usually a single-line file, I only broke it down here for readability purposes.

Upvotes: 3

Related Questions