0

We have been using HttpConfiguration.Routes.MapHttpRoute with routes that use URLs as parameters and it has been working fine for years.

//load image from remote server
config.Routes.MapHttpRoute(
    name: "remote-image",
    routeTemplate: "rimage/{*path}",
    defaults: new { controller = "WebApiClient", action = "rimage" }
);

Recently we upgraded few 3rd party NuGet packages that also upgraded dependency packages. After that this particular route template is not responding the requests that contain period.

For instance this works: https://my.domain.com/rimage/remote/domain/name/some-image

But this does not: https://my.domain.com/rimage/remote/domain/name/some-image.jpg

What can I add to the template to make sure period can be used?

joym8
  • 4,014
  • 3
  • 50
  • 93
  • This might be relevant still: https://stackoverflow.com/questions/2310187/asp-net-mvc-route-ids-with-a-period – rbonestell Apr 21 '20 at 16:04
  • @rbonestell but it has been working without the need of updating web.config? – joym8 Apr 21 '20 at 19:27
  • 1
    My answer to this question might also be helpful, although you still have to add to the config. Essentially it boils down to "anything containing a period is considered a file" and you need to tell the request handler to ignore it. https://stackoverflow.com/questions/52111209/http-route-without-parameters-and-a-point-inside-the-route/52116927#52116927 – Craig H Apr 22 '20 at 13:42
  • 1
    @CraigH yes that answer saved us. – joym8 Apr 23 '20 at 23:42

0 Answers0