Description
A bit obscure I know, but I came across this bug when I was doing daft things to my Api to see if it reacted OK (users do daft things occasionally!)
Its easy to reproduce with the Asp.Net Core samples HelloWorldController. Just add an HttpPost action that does anything you like - I have added one called "NotAGet"
`[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/[controller]")]
public class HelloWorldController : Controller
{
// GET api/v{version}/helloworld
[HttpGet]
public IActionResult Get() => Ok(new { Controller = GetType().Name, Version = HttpContext.GetRequestedApiVersion().ToString() });
// GET api/v{version}/helloworld/{id}
[HttpGet("{id:int}", Name = "GetMessageById")]
public IActionResult Get(int id) => Ok(new { Controller = GetType().Name, Id = id, Version = HttpContext.GetRequestedApiVersion().ToString() });
// POST api/v{version}/helloworld
[HttpPost]
public IActionResult Post() => CreatedAtRoute("GetMessageById", new { id = 42 }, null);
[HttpPost("notAGet")]
public IActionResult NotAGet() => CreatedAtRoute("notAGet", new { id = 43 }, null);
}`
Run the project and paste the following into a browser address bar:
http:///api/v1/helloworld/notAGet
You will get an unhandled ArgumentNullException in the application, ultimately resulting in an HTTP 500 being returned to the browser.
Obviously this is a pretty low priority as it only occurs when someone does something silly, but ideally it still shouldn't throw an unhandled exception...