I have hard time to make working attribute routing for urls ending with .json. It is working for GET requests and not working with POST requests. Not sure what is wrong.
I have 2 controllers. In one controller I have:
[HttpGet]
[Route("stock.json")]
public HttpResponseMessage Stocks(int? limit = null, int? offset = null)
In another controller I have:
[HttpPost]
[Route("orders.json")]
public HttpResponseMessage AddOrder([FromBody]OrderRest order)
In web.config:
<system.webServer>
<handlers>
<add name="Json" path="*.json" verb="GET" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
First works perfectly fine, the second does not. As soos as I change POST to GET it is working.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Very silly. In config I have configured it only for verb="GET". Just changed to verb="GET,POST,PUT".
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0