我在Angular中有一个web应用程序,我还在这个web应用程序中创建了WCF服务。当我运行web应用程序时,URL是localhost:553536/#/Page。服务地址为localhost:553536/Service/Service/svc。我托管了web应用程序,web应用程序和WCF服务都运行良好。但我想在不同的端口或不同的地址上托管web服务。我怎么能做到这一点。这是我的web.config
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="" >
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<bindings>
<wsDualHttpBinding>
<binding name="MobileServiceBinding" closeTimeout="00:00:05" openTimeout="00:00:05">
<readerQuotas maxDepth="32" maxStringContentLength="5242880" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</wsDualHttpBinding>
</bindings>
<services>
<service name="Web.Mobile.MobileService" >
<endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="MobileServiceBinding" contract="Web.Mobile.IMobileService" />
</service>
</services>
</system.serviceModel>
如何为WCF服务分配不同的地址?
当endpoint
配置的address
为空时,这听起来像是项目设置中自动分配的端口。
在部署web服务时,只需根据需要修改address
<services>
<service name="Web.Mobile.MobileService" >
<endpoint address="http://whatever.you.like:1337" binding="wsDualHttpBinding" bindingConfiguration="MobileServiceBinding" contract="Web.Mobile.IMobileService" />
</service>
</services>
或修改项目配置,以便在Visual Studio中运行/调试web服务。