1

I have a web service deployed on IIS 8.5 (Windows Server 2012 R2) which has to be called passing four arguments. They are not optional, and are to be included directly in the URL, without a query string, as such:

.. api/myservice/argument1/argument2/argument3/argument4

If I try to call it with the URL written above, it answers and gives the expected response. However, a 404 - Not Found error is given instead when trying to use real production-like arguments as such:

api/myservice/AAAA_AAAAA.AAA_AAA_AA_AA_AAA_000000_000000_000000/333/AAA/AAA.AAA.AA.AA.AAA.000000.000000.000000

I thought the multiple dots raised the issue, so I replaced each one of them with %2E, but nothing changed. I've searched for already answered questions: I tried this and this, to no avail.

What is the problem with that production-like URL? Here is the code of the API:

[RoutePrefix("api/myservice")]
public class MyServiceController : ApiController
{
   [HttpGet]
   [Route("{argument1}/{argument2}/{argument3}/{argument4}")]
   public string StartValidation(string argument1, string argument2, string argument3, string argument4)
   {
      // operations...
   }
}

I traced the request with IIS Failed Request Tracing as suggested in an answer, but I'm not able to find a clue in the resulting log: enter image description here Can anyone help me?

StackLloyd
  • 409
  • 2
  • 9

3 Answers3

0

Enable failed request tracing on IIS to check.

https://learn.microsoft.com/en-us/iis/configuration/system.applicationhost/sites/site/tracefailedrequestslogging

Good possibility that IIS is rejecting these as part of URLScan (if enabled), but FRT will confirm.

Matt Evans
  • 7,113
  • 7
  • 32
  • 64
  • I installed the FRT, but I can't seem to find the logs for the failed request. Probably I'm not setting the rules for tracing correctly. In IIS manager, in the API options, I set the FRT rules as follows: **Path * | Associated Provider: ASP, ISAPI extension, WWW server | Status Codes: 404 | Time Taken: 00:00:00 | Entry Type: Local**. However, inetpub\logs\FailedReqLogFiles is empty. Can you help with configurating the correct rules? – StackLloyd May 23 '19 at 12:42
  • @StackLloyd you have to enable it also on your site. Drill down to site in IIS manager - > in the Actions pane (right hand side) click -> Failed Request tracing..., and enable in the dialog – Matt Evans May 23 '19 at 12:48
  • Ok maybe I got it. An XML was generated in the Logs folder after the failed request, but it's huge, I don't want to post it all here. What should I look for? – StackLloyd May 23 '19 at 12:53
0

First try to deploy it to your local Iis, if it works, means that your production can have a different configuration at the level of the IIS, or the compiled code is not the same as the one you have and you need to redeploy the api. If the api fails at the level of your local IIS and it runs properly from the vs(if you pass any parameter with the postman) you hit a backend breakpoint, then you have a wrong configuration on your deployment on your local IIS. If you never hit the breakpoint you have an error at the level of your code. Hope this helps

Zinov
  • 3,817
  • 5
  • 36
  • 70
  • If I start the API on my workstation in Visual Studio (version: 2015 Pro) in debug mode and send a request with Postman, the error showed by Postman is still **404 - Not Found.** – StackLloyd May 23 '19 at 12:46
0

I finally solved this. I added a piece code, provided by this answer to a quite identical question, to the web.config, but a different issue arose: it seemed IIS had to be run in "Integrated Mode". Thanks to the clue given by this answer to a question about this subsequent problem, I switched the Managed pipeline mode of the application pool where the API was deployed from Classic to Integrated, which allowed that code to work. The web API finally accepts arguments with periods.

StackLloyd
  • 409
  • 2
  • 9
  • This is an IIS configuration on your deployment, what is weird is why your route doesn't work, when I have a chance I will try it with asp.net 4.5 – Zinov May 23 '19 at 21:21