小编Ube*_*1.0的帖子

在Areas之外的MVC应用程序中托管WCF服务

我有一个MVC项目,在根目录中添加了一个名为WCF的文件夹。在此文件夹中,我创建了一个名为的WCF服务CustomFunctions。当我尝试启动该服务时,出现以下错误:

错误:无法从http://localhost/Viper/WCF/CustomFunctions.svc... 获取元数据。元数据包含无法解析的引用:

附加说明:

找不到类型'Viper.WCF.CustomFunctions',作为ServiceHost指令中的Service属性值提供,或在配置元素system.serviceModel / serviceHostingEnvironment / serviceActivations中提供。

我昨天遇到此错误,并花了一些时间在互联网上寻找答案。这使我对Web.config和Global.asax.cs进行了很多更改。昨天,它开始工作了,我停了下来。但是,当我今天早上回来时,它并没有再全部工作。在此期间,没有添加任何新内容,也没有更改任何代码。

我已经将以下内容添加到我的Web.config中:

<system.serviceModel>
<services>
  <service behaviorConfiguration="WCFBehavior" name="Viper.WCF.CustomFunctions">
    <endpoint address="" binding="wsHttpBinding" contract="Viper.WCF.ICustomFunctions">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost/Viper/WCF/CustomFunctions/" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="WCFBehavior">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" httpGetUrl=""/>
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel> 
Run Code Online (Sandbox Code Playgroud)

这给我Global.asax.cs:

public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.svc/{*pathInfo}");

        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // …
Run Code Online (Sandbox Code Playgroud)

c# model-view-controller wcf web-services metadata

4
推荐指数
1
解决办法
2697
查看次数

标签 统计

c# ×1

metadata ×1

model-view-controller ×1

wcf ×1

web-services ×1