I don’t know why after every release Microsoft is making things so confusing. I trying to develop WCF RESTful service. I’m using VS 2010 Premium with .Net 4. I have downloaded WCF REST Starter Kit and also downloaded WCF REST templates for VS 2010 from visual
studio gallery. (WCF REST Service Template 40(CS)
)
On all the learning videos & MSDN it says use WebServiceHost2 & WebServiceHost2Factory class for RESTful services, because these classes are specifically designed for REST services and they are included in Microsoft.ServiceModel.Web.dll. Also the examples
I have seen so far uses .svc file to host the service.
So I created a project using the WCF REST Template which I have downloaded from Visual Studio gallery. But it created a service class without using .svc file and also there is no reference to Microsoft.ServiceModel.Web.dll. After little bit of digging and
goggling I found its using RouteTable to add the service. Below is the code in global.ascx
RouteTable.Routes.Add(new ServiceRoute("Service1", new WebServiceHostFactory(), typeof(Service1)));
If you note, its not using WebServiceHost2Factory instead its using WebServiceHostFactory.
So now I’m completely confused which is the best way to develop & start WCF RESTful service and what’s the advantage of one over other. I know both approaches will work but which one is preferred approach
lax4u
Participant
1592 Points
902 Posts
RouteTable vs WebServiceHost2Factory...which one to use & why?
Jan 06, 2012 09:03 PM|LINK
I don’t know why after every release Microsoft is making things so confusing. I trying to develop WCF RESTful service. I’m using VS 2010 Premium with .Net 4. I have downloaded WCF REST Starter Kit and also downloaded WCF REST templates for VS 2010 from visual studio gallery. (WCF REST Service Template 40(CS) )
On all the learning videos & MSDN it says use WebServiceHost2 & WebServiceHost2Factory class for RESTful services, because these classes are specifically designed for REST services and they are included in Microsoft.ServiceModel.Web.dll. Also the examples I have seen so far uses .svc file to host the service.
So I created a project using the WCF REST Template which I have downloaded from Visual Studio gallery. But it created a service class without using .svc file and also there is no reference to Microsoft.ServiceModel.Web.dll. After little bit of digging and goggling I found its using RouteTable to add the service. Below is the code in global.ascx
RouteTable.Routes.Add(new ServiceRoute("Service1", new WebServiceHostFactory(), typeof(Service1)));If you note, its not using WebServiceHost2Factory instead its using WebServiceHostFactory.
So now I’m completely confused which is the best way to develop & start WCF RESTful service and what’s the advantage of one over other. I know both approaches will work but which one is preferred approach
Again, im using VS 2010, .Net 4, IIS 7.5
lax4u
Participant
1592 Points
902 Posts
Re: RouteTable vs WebServiceHost2Factory...which one to use & why?
Jan 10, 2012 02:51 PM|LINK
in case if anyone looking for clarification
http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/22517d13-4db2-48f7-9f7d-7420eee106b5
http://wcf.codeplex.com/discussions/285526