0

I am currently working on a Web API that must return a list of servers or a single server if the FQDN is passed to the API.

The route is:

"api/Servers/{fqdn}"

When I perform a GET from a REST Client on a URL like this:

GET api/Servers/hostname.domain.com

IIS returns a 404 Not Found.

When I perform a GET without a "." in the URL parameter:

GET api/Servers/hostname_domain_com

It gets routed successfully to my API controller.

When I get the 404 error page, it is the IIS 8 error page. This leads me to believe that when there is a "." in the URL that IIS does not even pass it to the MVC pipeline and non of my code is executed. Could it be because IIS is trying to find another handler for the request as it looks like I am requesting a ".com" file extension. But this is just my assumption.

Has anyone experienced this before and if so how did you get around it?

2 Answers 2

1

Add <modules runAllManagedModulesForAllRequests ="true"/> under <system.webServer> in Web.config.

Sign up to request clarification or add additional context in comments.

2 Comments

Just to add to this answer, the problem is when IIS sees the a.com it thinks that you are trying to access a static file, and so does not dispatch the request to the ASP.NET pipeline. By adding the line that Badri suggested, you can override this behavior.
Good addition to the answer because it contained only the how-part but not the why-part. Thanks.
0

i think you need to encode the url before transfer it to the server. There is a javascript function urlencode. you can check it.

1 Comment

Url encoding the fqdn does not help, as "www.google.com" url encoded is "www.google.com" using function encodeURIComponent()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.