WCF Service support file jsdebug fails to load

2020-07-17 02:42发布

I have a WCF service that gets called from client side JavaScript. The call fails with a Service is null JavaScript error. WebDevelopment helper trace shows that the calls to load the jsdebug support file results in a 404 (file not found) error.

Restarting IIS or clearing out the Temp ASP.Net files or setting batch="false" on the compilation tag in web.config does not resolve the problem

From the browser

https://Myserver/MyApp/Services/MyService.svc displays the service metadata

however

https://Myserver/MyApp/Services/MyService.svc/jsdebug results in a 404.

The issue seems to be with the https protocol. With http /jsdebug downloads the supporting JS file.

Any ideas?

TIA

3条回答
仙女界的扛把子
2楼-- · 2020-07-17 02:46

Figured it out!

Here is the services configuration section from web.config

Look at the bindingConfiguration attribute on the endpoint. The value "webBinding" points to the binding name="webBinding" tag in the bindings and that is what tells the service to use Transport level security it HTTPS. In my case the attribute value was empty causing the webservice request to the /js or /jsdebug file over HTTPS to fail and throw a 404 error.

<services>
      <service name="MyService">
        <endpoint address="" behaviorConfiguration="MyServiceAspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webBinding" contract="Services.MyService" />
      </service>
    </services>
    <bindings>
      <webHttpBinding>
        <binding name="webBinding">
          <security mode="Transport">
          </security>
        </binding>
      </webHttpBinding>
    </bindings>

Note that the bindingConfiguration attribute should be empty ("") if the service is accessed via http instead of https (when testing on local machine with no certs)

Hope this helps someone.

查看更多
太酷不给撩
3楼-- · 2020-07-17 02:59

For me the issue was the following; we added MVC to a solution with routing. Our WCF services were not being ignored. I resolved this by adding the following rule (where "WCF" is the folder we keep our services in).

routes.IgnoreRoute("WCF/{*pathInfo}");

Hope that saves somebody a few hours.

查看更多
做自己的国王
4楼-- · 2020-07-17 03:01

If you still get the same error after all your possible work done. Just add a "AJAX Enabled WCF-Service".

查看更多
登录 后发表回答