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 ...
随机推荐
- js 关于时间
var myDate = new Date(); myDate.getYear(); //获取当前年份(2位) myDate.getFullYear(); //获取完整的年份(4位,1970-???? ...
- PHP 判断一个字符是否在字符串中
strpos() - 查找字符串 在另一字符串中 第一次出现的位置(区分大小写) stripos() - 查找字符串 在另一字符串中 第一次出现的位置(不区分大小写) strrpos() - 查找字符 ...
- Map使用操作系统内存的情况
public static void main(String[] args) { System.out.println("程序启动-->可用内存:"+(getSystemMe ...
- zabbix监控超详细搭建过程(转)
监控及zabbix 目录: 1 监控分类... 1 1.1 硬件监控... 1 1.2 系统监控... 2 1.3 网络监控... 3 1.4 ...
- 可横向滑动的vue tab组件
示例 前端使用技术:框架->vue 组件>ly-tab一个用于移动端的可触摸滑动具有回弹效果的可复用Vue组件 ly-tab 介绍地址 ly-tab npm地址 使用步骤 1,引入包,定义 ...
- jmeter搭建
jdk 1.8的地址 链接:https://pan.baidu.com/s/1eEyYbzo1Tfbvbmf_vN2yUA 密码:6dxi 1.安装JDK 选择安装目录 安装过程中会出现两次 安装提 ...
- [USACO08FEB]修路Making the Grade 动态规划
对的\(n^3\)的程序调了一个月了,惊了... HSZ学oi\(\Longleftrightarrow\)闭眼学oi 要不是翻旧账还看不见.. 这是有\(n^2\)做法的. 参见LYD的书P244 ...
- 为了使界面组件更圆滑,Swing,且跨系统
- tableView计算动态行高的总结
研究tableView怎么计算动态行高研究了两天一直还不太会,今天最终做出来了想要的效果. 首先.我在网上搜集了非常多资料,各种大神的总结,然后開始看.研究.试验,基本思路都是一样的. 1.一定要将l ...
- android setCookie 免登录
CookieSyncManager.createInstance(getActivity()); CookieManager cookieManager = CookieManager.getInst ...