Problems debugging WCF Web Api REST service

810 views Asked by At

So I have created a REST service based on WCF Web API. It runs fine on my local IIS. But when I deploy it to an external server it doesnt work.

In my global.asax.cs I map a route "MyRoute" to a class MyHandler. So whenever I go to http://localhost/MyApplication/MyRoute/MyResource I get a valid response.

However on the external server after deployment if I open http://localhost/MyApplication/MyRoute/MyResource in IE I get "Internet Explorere cannot display the webpage" (FF = "The connection was resset - The connection to the server was reset while the page was loading")

If I enter an invalid resource name: http://localhost/MyApplication/MyRoute/adfasdf I get the same result on the external server as I get locally: "Endpoint not found".

Furthermore, I have tried removing all logic from the method in MyHandler that /MyRoute/MyResource is mapped to, to see there was something in that code that was causing the request to fail, but the result remains.

My best guess is that the issue somehow is with the route mapping.

I'd be really thankful for help either in this specific case I am having, or more generally on how to debug this. One frustration is that I am not even aware on where I can find error logs. I have looked in the event viewer, but can't find anything and don't know where to look more.

I'd be glad to post some code if that would help.

edit:

Ok, So I solved the issue. It was a routing thing. I solved it by including this in the web.config:

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
      <modules runAllManagedModulesForAllRequests="true">
          <remove name="UrlRoutingModule" />
          <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />       
      </modules>
  </system.webServer>

I still wouldn't mind understanding the mechanics behind these modules. Where are they defined? Is there a config file for the server defines which modules are loaded since apparently this differs somehow between my local IIS and the external one?

... And I still don't know where the logs are.

1

There are 1 answers

0
Alexander Zeitler On

When hosting on IIS, Web API uses the same URL routing module as ASP.NET (MVC) to select the endpoint. If you're self hosting, it doesn't have to.