开发者

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 hel开发者_JS百科l 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜