[英]WCF AJAX enabled service created OK, but method returns 404
這是我的第一個 WCF 服務,請諒解。 :)
通過瀏覽器導航到服務 url 時,會加載服務頁面。 好的。 當我嘗試添加“/DoWork”以訪問默認創建的方法時,我收到 404 錯誤。
我一直在瘋狂嘗試不同的教程建議。 沒有任何效果。 我一定錯過了一些簡單的東西。 服務器級別可能未啟用某些內容? 我認為VS添加的WCF代碼可以正常工作,對嗎?
為什么是404?????? 我錯過了什么????
感謝您的任何幫助和最好的問候,
烏達爾
這是web.config的相關部分
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="NativeAppConnectorWCFAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<services>
<service name="NativeAppConnectorWCF">
<endpoint address="" behaviorConfiguration="NativeAppConnectorWCFAspNetAjaxBehavior"
binding="webHttpBinding" contract="NativeAppConnectorWCF" />
</service>
</services>
</system.serviceModel>
如果使用 webhttpbinding,則需要在端點行為中添加 webHttp:
<endpointBehaviors>
<behavior name="ESEndPointBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
這是我的配置文件,我啟用了幫助文檔:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<system.serviceModel>
<services>
<service name="Demo_rest_ConsoleApp.Service1" behaviorConfiguration="ServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8763/TEST/"/>
</baseAddresses>
</host>
<endpoint address=""
binding="webHttpBinding"
contract="Demo_rest_ConsoleApp.IService1" behaviorConfiguration="ESEndPointBehavior"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="ESEndPointBehavior">
<webHttp helpEnabled="true"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceThrottling maxConcurrentCalls="1" maxConcurrentInstances="1" maxConcurrentSessions="1"/>
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
如果問題仍然存在,請隨時告訴我。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.