我有一个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)