Custom Hosting in IIS/WAS
常常需要与宿主实例进行交互。这对于使用自托管的方式是不可或缺的。当使用IIS或WAS时,不能直接访问宿主。为了克服这个障碍,WCF提供了一个宿主工厂。在.svc文件中使用Factory标签,使用此工厂,而不使用默认工厂:
<%@ ServiceHost
Language = "C#"
Debug = "true"
CodeBehind = "~/App_Code/MyService.cs"
Service = "MyService"
Factory = "MyServiceFactory"
%>
当不显示使用.svc文件时,也可以在配置文件中指定宿主工厂:
“<serviceActivations>
<add relativeAddress = "MyService.svc"
service = "MyService"
factory = "MyServiceFactory"
/>
</serviceActivations>” 摘录来自: Juval Löwy and Michael Montgomery. “Programming WCF Services”。 iBooks.
自定义宿主工厂类必须继承自ServiceHostFactory类并重写虚方法CreateServiceHost():
“public class ServiceHostFactory : ...
{
protected virtual ServiceHost CreateServiceHost(Type serviceType,
Uri[] baseAddresses);
//More members
}” 摘录来自: Juval Löwy and Michael Montgomery. “Programming WCF Services”。 iBooks.
例如:
“class MyServiceFactory : ServiceHostFactory
{
protected override ServiceHost CreateServiceHost(Type serviceType,
Uri[] baseAddresses)
{
ServiceHost host = new ServiceHost(serviceType,baseAddresses); //Custom steps here return host;
}
}” 摘录来自: Juval Löwy and Michael Montgomery. “Programming WCF Services”。 iBooks.
CreateServiceHost()方法其实就相当于IIS或WAS托管服务的Main()方法,你可以以这样的目的来使用它。
尽管对于从 CreateServiceHost 返回的 ServiceHost 可以执行什么操作没有技术限制,但建议您尽可能使工厂实现简单化。如果有大量的自定义逻辑,最好将这些逻辑放入宿主内而不是工厂内,以便可以重用它们。
参考:
Juval Löwy and Michael Montgomery. “Programming WCF Services” 使用 ServiceHostFactory 扩展宿主(https://msdn.microsoft.com/zh-cn/library/aa702697.aspx)
Custom Hosting in IIS/WAS的更多相关文章
- ASP.NET Core In Process Hosting on IIS with ASP.NET Core 2.2(转载)
ASP.NET Core 2.2 has been out for a while now and with it come some significant improvements to the ...
- Using Custom Domains With IIS Express In Asp.Net Core
IIS Express是一个Mini版的IIS,能够支持所有的Web开发任务,但是这种设计有一些缺陷,例如只能通过localhost:<port>的方式来访问我们的应用程序,看起来就有点不 ...
- Getting Started with OWIN and Katana(Console 代替iis 制作 web服务的简单方案)
Open Web Interface for .NET (OWIN) defines an abstraction between .NET web servers and web applicati ...
- [转]ASP.NET Core 1 Deploy to IIS
本文转自: http://webmodelling.com/webbits/aspnet/aspnet-deploy-iis.aspx 15 Sep 2016. This tutorial will ...
- ASP.NET Core 2.2 和之前版本区别: 可以在IIS上进行ASP.NET核心进程托管 (翻译)
原文链接: https://weblog.west-wind.com/posts/2019/Mar/16/ASPNET-Core-Hosting-on-IIS-with-ASPNET-Core-22 ...
- 000.Introduction to ASP.NET Core--【Asp.net core 介绍】
Introduction to ASP.NET Core Asp.net core 介绍 270 of 282 people found this helpful By Daniel Roth, Ri ...
- .NET Best Practices
Before starting with best practices tobe followed, it is good to have clear understanding of how mem ...
- Linux上运行NET
今天尝试了下Ubuntu上运行NET程序,按照 https://github.com/aspnet/Home 的指引,一步一步来: 1.安装DNVM(原名KVM) Linux控制台下输入 curl - ...
- WCF学习系列二---【WCF Interview Questions – Part 2 翻译系列】
http://www.topwcftutorials.net/2012/09/wcf-faqs-part2.html WCF Interview Questions – Part 2 This WCF ...
随机推荐
- 读书笔记「Python编程:从入门到实践」_2.变量和简单数据类型
做了大半年RPA了,用的工具是Kapow. 工作没有那么忙,不想就这么荒废着,想学点什么.就Python吧. 为期三个月,希望能坚持下来. 2.1 变量的命名和使用 变量名只能包含字母.数字和下划线. ...
- <转>统计源代码行数的一些实现方法
这个问题的思考其实对于某一种语言而言,基本都能实现,只是简单和复杂而已.而此次我讨论就是只是在linux下面使用了shell和c对源代码进行行 数的讨论.本打算是实现一个python版本的,由于pyt ...
- Python基础:dict & set
一 :dict 1:Python内置了字典:dict的支持,dict全称dictionary,在其他语言中也称为map,使用键-值(key-value)存储,具有极快的查找速度. eg: dict查找 ...
- JS 封装一个判断闰年平年的方法 aa(nian)
nn(2017) function nn (nian){ if(nian%4 == 0 && nian%100 !== 0 || nian%400 ==0 ) { alert(&quo ...
- 关于配置websocket,nginx转发https至wss问题
在本地测试通过的socket,再放到现在的有nginx代理之后发现会报:failed: Error in connection establishment: net::ERR_NAME_NOT_RES ...
- 元素隐藏的方式之--hidden,display,visibility
<html lang="en"> <head> <meta charset="UTF-8"> <title>标签 ...
- linux 编译网卡驱动
将smsc7500网卡驱动拷贝到/drive/net/usb文件夹下 拷贝ioctl_7500.h smsc7500usbnet.c smsc7500version.h smsclan7500.h ...
- LoadRunner性能测试-下载文件脚本
Action() { intflen; //定义一个整型变量保存获得文件的大小 longfiledes; //保存文件句柄 charfile[]="\0"; //保存文件路径及文件 ...
- LaTeX soul包
本系列文章由 @yhl_leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/50774955 详细的soul包的官方P ...
- mysql修改配置文件
在Apache, PHP, MySQL的体系架构中,MySQL对于性能的影响最大,也是关键的核心部分.对于Discuz!论坛程序也是如此,MySQL的设置是否合理优化,直接影响到论坛的速度和承载量!同 ...