加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

.net – ServiceHost和WebServiceHost有什么区别?

发布时间:2020-12-16 07:12:07 所属栏目:asp.Net 来源:网络整理
导读:对于.Net4,以下是否有任何区别 Uri baseAddress = new Uri("http://localhost:8080/test");ServiceHost host = new ServiceHost(typeof(TestService),baseAddress);host.Open(); 和 Uri baseAddress = new Uri("http://localhost:8080/test");WebServiceHost
对于.Net4,以下是否有任何区别

Uri baseAddress = new Uri("http://localhost:8080/test");
ServiceHost host = new ServiceHost(typeof(TestService),baseAddress);
host.Open();

Uri baseAddress = new Uri("http://localhost:8080/test");
WebServiceHost host = new WebServiceHost(typeof(TestService),baseAddress);
host.Open();

所有的书都推荐使用webServiceHost,但为什么我看不出差异?

解决方法

WebServiceHost类基于ServiceHost类.

它默认带有WebHttpBinding和WebHttpBehavior. (好的是你不需要配置文件,只是为了简单使用.)

从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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读