Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

In my knowledge, the RESTful WCF still has ".svc" in its URL.

For example, if the service interface is like

[OperationContract]
[WebGet(UriTemplate = "/Value/{value}")]
string GetDataStr(string value);

The access URI is like "http://machinename/Service.svc/Value/2". In my understanding, part of REST advantage is that it can hide the implementation details. A RESTful URI like "http://machinename/Service/value/2" can be implemented by any RESTful framework, but a "http://machinename/Service.svc/value/2" exposes its implementation is WCF.

How can I remove this ".svc" host in the access URI?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.2k views
Welcome To Ask or Share your Answers For Others

1 Answer

I know this post is a bit old now, but if you happen to be using .NET 4, you should look at using URL Routing (introduced in MVC, but brought into core ASP.NET).

In your app start (global.asax), just have the following route configuration line to setup the default route:

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

then your URLs would look like this:

http://servername/mysvc/value/2

HTH


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...