我在一个用于ajax调用的项目中设置了WCF服务。我可以毫无问题地访问服务的主页面(〜/ AjaxService.svc),但是当我尝试访问端点时,它会给出404错误,而不是“找不到端点”。信息。
我团队中的其他开发人员使用完全相同的代码分支,没有任何问题。这在过去有效,并且最近才开始显示此错误。在iis中,代码运行的应用程序使用的是asp.net 4.0,但我确实有使用asp.net 2.0的旧版本,这些端点可以工作。
AjaxService.svc
< ServiceHost Language =“C#”Debug =“true”Service =“MyCompanyService.AjaxService”>
的web.config
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="MyCompanyService.AjaxServiceAspNetAjaxBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="MyCompanyService.AjaxService">
<host>
<baseAddresses>
<add baseAddress="/ajax/AjaxService.svc"/>
</baseAddresses>
</host>
<endpoint address="/service1" behaviorConfiguration="MyCompanyService.AjaxServiceAspNetAjaxBehavior" binding="webHttpBinding" contract="MyCompanyService.IService1"/>
<endpoint address="/service2" behaviorConfiguration="MyCompanyService.AjaxServiceAspNetAjaxBehavior" binding="webHttpBinding" contract="MyCompanyService.IService2"/>
<endpoint address="/service3" behaviorConfiguration="MyCompanyService.AjaxServiceAspNetAjaxBehavior" binding="webHttpBinding" contract="MyCompanyService.IService3"/>
<endpoint address="/service4" behaviorConfiguration="MyCompanyService.AjaxServiceAspNetAjaxBehavior" binding="webHttpBinding" contract="MyCompanyService.IService4"/>
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="webBinding">
<security mode="Transport"/>
</binding>
</webHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>