Asp.net Web API属性路由不适用于“。”

时间:2016-04-05 17:17:14

标签: c# asp.net-web-api iis-express attributerouting

带有“。”的属性路由。在我的Web API项目中不起作用 示例网址不起作用

  

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

        }
    }

如果我删除了。然后扩展然后它工作。所以,这有效......

  

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

    }
}

我在本地使用IIS Express。

0 个答案:

没有答案