基本思路

1、新建WCF应用程序
2、注册路由(可省略,则用/….svc/….访问)
配置文件

  <appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2"/>
</system.web>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="NewBinding0" />
</webHttpBinding>
</bindings>
<services>
<service name="WcfService4.Service1">
<endpoint address="/service" behaviorConfiguration="web" binding="webHttpBinding"
bindingConfiguration="" contract="WcfService4.IService1" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<!--<protocolMapping>
<add binding="basicHttpBinding" scheme="http" />
</protocolMapping>-->
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
若要在调试过程中浏览 Web 应用程序根目录,请将下面的值设置为 True。
在部署之前将该值设置为 False 可避免泄露 Web 应用程序文件夹信息。
-->
<directoryBrowse enabled="true"/>
</system.webServer>

访问uri:http://localhost:27472/Service1.svc/service/GetData/1
3、写接口和.svc(服务) 与WCF库完全相同
4、Release模式下生成项目并发布(避免源代码暴露)
5、IIS下托管
托管成网站(添加网站),确定端口
访问:http://localhost:端口号/Service1.svc/service/GetData/1
localhost可改为IP地址


注意

服务引用BLL、DAL+EF之类的,引用项目,并把相关配置拷贝到最后服务的配置文件里面
比如,数据库连接字符串,EF相关配置,其他功能授权相关内容等等


配置文件参考

服务器发布后的配置文件:(Web.config)
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="NewBinding0" />
</webHttpBinding>
</bindings>
<services>
<service name="WcfService4.Service1">
<endpoint address="/service" behaviorConfiguration="web" binding="webHttpBinding" bindingConfiguration="" contract="WcfService4.IService1" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<!--<protocolMapping>
<add binding="basicHttpBinding" scheme="http" />
</protocolMapping>-->
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<!--
若要在调试过程中浏览 Web 应用程序根目录,请将下面的值设置为 True。
在部署之前将该值设置为 False 可避免泄露 Web 应用程序文件夹信息。
-->
<directoryBrowse enabled="true" />
<!--以下是IIS托管后自动添加的部分-->
<handlers>
<remove name="ISAPI-dll" />
<add name="test2" path="*.svc" verb="*" modules="IsapiModule" scriptProcessor="D:\WcfService4\bin\WcfService4.dll" resourceType="File" preCondition="bitness32" />
<add name="test" path="*.dll" verb="*" modules="IsapiModule" scriptProcessor="Dhua555:\WcfService4\bin\WcfService4.dll" resourceType="File" preCondition="bitness32" />
</handlers>
</system.webServer>

WCF服务的IIS托管(网站托管)的更多相关文章

  1. WCF服务的IIS托管(应用程序)

    基本思路 建立与发布参考网站托管 在IIS中某一网站,选择添加应用程序   访问服务uri:http://localhost/wcfAppTest/Service1.svcwcfAppTest/Ser ...

  2. WCF 一步一步 发布 WCF服务 到 IIS (图)

    WCF 一步一步 发布 WCF服务 到 IIS (图) 使用VS自带的WCFSVCHost(WCF服务主机)发布WCF服务,时刻开发人员测试使用. 下面我们来看一下如何在IIS中部发布一个WCF服务. ...

  3. .Net WCF服务部署IIS详细解析

    官方解析:Windows Communication Foundation(WCF)是由微软开发的一系列支持数据通信的应用程序框架,可以翻译为Windows 通讯开发平台.整合了原有的windows通 ...

  4. WCF服务部署IIS

    一.将WCF服务部署到IIS上  [转载自简单笑容——http://www.cnblogs.com/skdsxx/p/5072726.html ] 1.首先检测电脑上是否安装了IIS,一般来说Win7 ...

  5. WCF服务寄宿IIS与Windows服务 - C#/.NET

    WCF是Windows平台下程序间通讯的应用程序框架.整合和 .net Remoting,WebService,Socket的机制,是用来开发windows平台上分布式开发的最佳选择.wcf程序的运行 ...

  6. WCF服务寄宿IIS与Windows服务

      WCF是Windows平台下程序间通讯的应用程序框架.整合和 .net Remoting,WebService,Socket的机制,是用来开发windows平台上分布式开发的最佳选择.wcf程序的 ...

  7. WCF入门(六)---主机WCF服务

    建立一个WCF服务后,下一步就是托管它,以便客户端应用程序可以使用,这就是所谓的WCF服务托管. WCF服务可以通过使用任何的四种方法如下托管. IIS主机 - IIS是Internet信息服务的缩写 ...

  8. Azure开发者任务之七:在Azure托管服务中托管WCF服务角色

    在一个托管服务中托管一个WCF服务角色和托管一个ASP.Net Web Role基本类似. 在上一篇文章中,我们学习了如何使用WCF Service Web Role. 在本文中,我会对上一篇文章进行 ...

  9. 创建WCF服务寄宿到IIS

    一.WCF简介: Windows Communication Foundation(WCF)是由微软开发的一系列支持数据通信的应用程序框架,可以翻译为Windows 通讯开发平台. 整合了原有的win ...

随机推荐

  1. ant脚本中设置环境变量

    http://blog.csdn.net/quqi99/article/details/5329841

  2. 【转】优先队列priority_queue 用法详解

    http://www.cnblogs.com/void/archive/2012/02/01/2335224.html 优先队列是队列的一种,不过它可以按照自定义的一种方式(数据的优先级)来对队列中的 ...

  3. scss 常用语法

    点击查看 sass 官方文档 1.编译 初学可以在atom 中编译 安装命令 gem install sass atom中安装atom-sass ,mac 中"control+option+ ...

  4. Linux环境变量具体解释

    设置环境变量 profile和bashrc文件 /etc/profile:在登录时,操作系统定制用户环境时使用的第一个文件.此文件为系统的每一个用户设置环境信息,当用户第一次登录时,该文件被运行. 并 ...

  5. DesignPattern_Java:SingletonPattern

    单例模式 SingletonPattern Ensure a class has only one instance,and provide a global point of access to i ...

  6. 基于webRTC技术 音频和视频,IM解

    由于原来的文章 http://blog.csdn.net/voipmaker  转载注明出处. 基于WebRTC技术可实现点对点音视频.即时通信.视频会议.最新的系统组件包含: TeleICE NAT ...

  7. setTimeout里的函数是何时进入任务队列里的

    先看一段代码 setTimeout(function () { console.log('abc') }, 1000) for (var i = 0; i <= 800000000; i++) ...

  8. android打包SDK具体操作(包含第三方的jar一起打包)

    一.背景 因为最近编写的android项目,需要编写对应的SDK给别人使用,还好以前我都是拆成module写的,所以还不太费工夫,不过因为一些module里面包含第三方的jar,所以打包有点麻烦 二. ...

  9. Ultra-wideband (UWB) secure wireless device pairing and associated systems

    Methods and systems are disclosed for ultra-wideband (UWB) secure wireless device pairing. Secure pa ...

  10. qemu使用copy-on-write(COW)磁盘

    写时复制(copy-on-write,缩写COW)技术不会对原始的镜像文件做更改,变化的部分写在另外的镜像文件中,这种特性在qemu中只有QCOW格式支持,多个 COW 文件可以指向同一映像同时测试多 ...