gpt4 book ai didi

c# - 未找到 WCF 端点

转载 作者:太空狗 更新时间:2023-10-30 00:32:52 26 4
gpt4 key购买 nike

我正在按照一本书中的教程为 Windows Phone 实现推送通知。这是服务的标记:

<%@ ServiceHost Language="C#" Debug="true" Service="Service.PushService" CodeBehind="PushService.svc.cs" Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>

如你所见,添加了一个工厂,虽然我不太明白它是做什么用的。运行该服务时,出现 “未找到端点” 错误。当我从标记中删除工厂时,错误消失,但我得到一个空白页面。

知道什么可能导致此错误或如何修复它吗?如果您需要更多代码,请告诉我。

谢谢

编辑:我的 web.config:

<?xml version="1.0"?>
<configuration>

<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>

</configuration>

最佳答案

您在 web.config 中缺少端点配置。

将此添加到您的 web.config 中:

<system.serviceModel>
<services>
<service name="Service.PushService">
<endpoint address="" binding="basicHttpsBinding"
contract="Service.IPushService" />
</service>
</services>
</system.serviceModel>

关于c# - 未找到 WCF 端点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15130879/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com