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.

4
  • Are you running on IIS? If so, Static File handlers might get in your way Commented Apr 5, 2016 at 17:22
  • @PeterLillevold, yes I am using IIS Express. I have edited my question. Any solution? Commented Apr 5, 2016 at 17:24
  • 3
    Try editing the how the site deals with HTTP handlers: stackoverflow.com/questions/11728846/… Commented Apr 5, 2016 at 17:24
  • @DavidOesterreich, please enter is an answer so that I can accept it. the runAllManagedModulesForAllRequests did the trick. Commented Apr 5, 2016 at 17:26

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.