本文没有使用 VS2010 中的标准 WCF 服务库项目模板,因此显然它缺少一些可能使其更容易在 IIS 上托管的东西。
有人可以提供必要的步骤(以及您希望包含的尽可能多的细节)以将此特定的 WCF 解决方案带到它托管在 IIS 7 上的阶段吗?
谢谢。
本文没有使用 VS2010 中的标准 WCF 服务库项目模板,因此显然它缺少一些可能使其更容易在 IIS 上托管的东西。
有人可以提供必要的步骤(以及您希望包含的尽可能多的细节)以将此特定的 WCF 解决方案带到它托管在 IIS 7 上的阶段吗?
谢谢。
现在从文章中,一旦您构建了服务类库项目,它将生成一个需要复制到 bin 文件夹的 .dll 文件。
现在创建一个包含以下内容的 .svc 文件:
<%@ServiceHost language=c# Debug="true" Service="TConvertAS.Services.TempConverter "%>
现在您的 web.config 应该如下所示:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0">
</compilation>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding>
<security mode="None">
</security>
</binding>
<services>
<service name="TConvertAS.Services.TempConverter">
<endpoint address="" binding="basicHttpBinding" name="Service1" contract="TConvertAS.Contracts.ITempConverter" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
完成上述操作后,只需确保您的应用程序需要配置在哪个应用程序池下运行即可。
现在只需右键单击虚拟目录下的 .svc 文件,然后单击浏览即可看到 WCF 服务页面。
(或者)
您可以直接将虚拟目录映射到 WCF 服务类库项目并将 svc 和 web.config 文件添加到 WCF 服务类库项目,而不是在 c:\intepub\wwwroot 下创建新文件夹。