Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Edited Unassigned: Web Api 2 Attribute Routing - Extension Issue [1203]

$
0
0
I am using the new attribute routing in Web Api 2 and am having the following issue with web hosting

I have set up extension mapping as follows:

```
config.Formatters.XmlFormatter.AddUriPathExtensionMapping("xml", "text/html");
config.Formatters.JsonFormatter.AddUriPathExtensionMapping("json", "application/json");

```
and have the following action:

```
[HttpGet("pets")]
[HttpGet("pets.{ext}")]
public HttpResponseMessage Get()
{
......
}
```

A GET request to /pets is successful, however a GET request to /pets.json results in a 404.

If I change the action to the following

```
[HttpGet("pets")]
[HttpGet("pets/{ext}")]
public HttpResponseMessage Get()
{
......
}
```

Then a GET request to /pets/json results in the content returning as JSON which is what I was expecting a GET to /pets.json to do.

This scenario was working using the existing attribute routing library in web api 1

Is there is an issue having a period in the route ?

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>