我正在尝试修复baseAddress
的错误。
当我尝试在MVC控制器中实例化服务主机时,它会引发异常。
无法使用绑定BasicHttpBinding找到与端点的scheme http匹配的基址。注册的基地址方案是[]。
这是我简单的c#代码
public ActionResult Index()
{
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
ServiceHost host = new ServiceHost(typeof(WCF_Example.Service1));
host.Open();
return View();
}
配置:
<service name="WCF_Example.Service1" behaviorConfiguration="mexBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:61940/"/>
</baseAddresses>
</host>
<endpoint
address="WCF_ServiceExample"
binding="basicHttpBinding"
contract="WCF_Example.IService1" />
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>