首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >托管在IIS地址下的wcf服务

托管在IIS地址下的wcf服务
EN

Stack Overflow用户
提问于 2011-10-12 17:16:21
回答 1查看 179关注 0票数 0

我有一个托管在IIS下的WCF服务。我有以下配置:

代码语言:javascript
复制
<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访问服务?

谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-10-20 19:25:54

为了拥有无扩展服务,您需要使用WCF4并在global.asax文件中初始化路由引擎,如下所示:

代码语言:javascript
复制
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)));
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7737777

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档