0

Attribute Routing with a "." is not working in my Web API project Sample URL which does not work

http://localhost:8082/image/TestImage.jpg

   [RoutePrefix("image")]
    public class TestController : ApiController
    {
        [Route("{uuid}.{extension}")]
        public HttpResponseMessage Get([FromUri(Name = "uuid")] string uuid,
            [FromUri(Name = "extension")] string extension)
        {
            // Not coming here with the URL http://localhost:8082/image/TestImage.jpg

        }
    }

If I remove the . and the extension then it works. So, this works...

http://localhost:8082/image/TestImage

[RoutePrefix("image")]
public class TestController : ApiController
{
    [Route("{uuid}")]
    public HttpResponseMessage Get([FromUri(Name = "uuid")] string uuid//,
        //[FromUri(Name = "extension")] string extension)
    {
        // Works with the URL http://localhost:8082/image/TestImage

    }
}

I am using IIS Express locally.

Peter Lillevold
  • 33,668
  • 7
  • 97
  • 131
Rwiti
  • 1,056
  • 1
  • 13
  • 31

0 Answers0