我有一个托管在IIS下的WCF服务。我有以下配置:
<services>
<service name="BillboardServices.LoginService" behaviorConfiguration="LoginServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://myip/LoginService/" />
</baseAddresses>
</host>
<endpoint address="" name="LoginService" binding="basicHttpBinding" contract="BillboardServices.ILoginService" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>如果我进入http://myip/LoginService/,我会得到404分。如果我输入http://myip/Service1.svc,就会得到服务元数据。
我需要对配置进行哪些更改才能通过漂亮的url访问服务?
谢谢。
发布于 2011-10-20 19:25:54
为了拥有无扩展服务,您需要使用WCF4并在global.asax文件中初始化路由引擎,如下所示:
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes();
}
private void RegisterRoutes()
{
// Edit the base address of Service1 by replacing the "Service1" string below
RouteTable.Routes.Add(new ServiceRoute("Service1", new WebServiceHostFactory(), typeof(Service1)));
}https://stackoverflow.com/questions/7737777
复制相似问题