0

I'm building out a series of MVC4 Web API's that return various bits of information. In most of the APIs, I'm conducting a GET method and passing a fully qualified domain name.

If I pass a short name the API returns the data as expected; however if I pass a fully qualified domain as an ID ending in ".com" I get a 404.

The API works fine when I debug within Visual Studio 2010; however once I "publish" the content, I start getting 404's. My initial hunch is that it's something with IIS; however I haven't been able to put my finger on the exact problem.

WORKS: /controller/action/server_shortname

404: /controller/action/server.domain.com

Any guidance would be appreciated. Thanks

tereško
  • 58,060
  • 25
  • 98
  • 150
Ryan Schlagel
  • 79
  • 1
  • 2
  • 8
  • Could you give some example of requests that are giving you a 404? In the example you give you just have controller and action, you're not passing in a domain – Kenneth May 16 '13 at 07:17
  • I updated the original description. Let me know if you need further info. Thanks – Ryan Schlagel May 16 '13 at 07:24
  • 1
    ehh. Why do you include the domain in the end? The dots should probably be urlencoded since they make IIS try to find a file extension named "com" – jgauffin May 16 '13 at 07:29

2 Answers2

0

If you are using .NET 4.0 you can use this in your web.config:

<httpRuntime relaxedUrlToFileSystemMapping="true" />

Apart from that you should also assure that you are running your applicationPool in integrated mode.

There are a few other posts that mention the same problem and depending on your configuration you could find your answer there:

Community
  • 1
  • 1
Kenneth
  • 28,294
  • 6
  • 61
  • 84
0

. has a special meaning in the path portion of an url and is interpreted by IIS as a extension separator.

If you are running in IIS Integrated Pipeline mode you could add the following handler to the <system.webServer> node:

<system.webServer>
    <handlers>
        ...
        <add 
            name="UrlRoutingHandler" 
            type="System.Web.Routing.UrlRoutingHandler, System.Web" 
            path="/api/*" 
            verb="*" />
    </handlers>
</system.webServer>

You will only need to adjust the path="/api/*" to the endpoint that you configured your API to listen to.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928