For .Net4, is there any difference between the following
Uri baseAddress = new Uri("http://localhost:8080/test");
ServiceHost host = new ServiceHost(typeof(TestService), baseAddress);
host.Open();
and
Uri baseAddress = new Uri("http://localhost:8080/test");
WebServiceHost host = new WebServiceHost(typeof(TestService), baseAddress);
host.Open();
all the books recommend using webServiceHost, but why I cannot see difference?
The WebServiceHost
class is based on the ServiceHost
class.
It comes with WebHttpBinding
and WebHttpBehavior
by default. (The nice thing is you don't need a configuration file, for simple use.)
From MSDN:
When you use WebServiceHost instead of ServiceHost, it will automatically create a Web endpoint for you using the base HTTP address and configure the injected endpoint with the WebHttpBehavior
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With