0

I'm creating a C# .net WebAPI using the following route mapping

config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
    "DefaultApiWithId",
    "api/{controller}/{id}",
    null,
    new { id = @"\d.+" });
config.Routes.MapHttpRoute(
    "UI",
    "{*url}",
    new { Controller = "UI", Action = "Index" }
    );

I have several actions of the format /action/{name} where the name could end with a dot (.). If the dot is anywhere, but at the end of the name, the URL gets resolved properly, but if the dot is at the end, the application says The resource cannot be found.

URLs that get resolved

  • https://foobar.com/foo/
  • https://foobar.com/foo.bar/
  • https://foobar.com/.foobar/
  • https://foobar.com/......a/
  • https://foobar.com/./ (gets converted to https://foobar.com/)

URLs that don't get resolved

  • https://foobar.com/foo./
  • https://foobar.com/foo.bar./
  • https://foobar.com/.foo.bar./
  • https://foobar.com/foo.bar
nick zoum
  • 7,216
  • 7
  • 36
  • 80

0 Answers0