I am experimenting with WebApi and created a controller with two methods.
First, I started with the following method:
[HttpGet] [Route("car/{registration}")] public object GetCarByRegistration(string registration) { return null; }
When debugging, I set a breakpoint on return null; checked url http://localhost:51245/api/car/yw25jdk , which works fine, visual studio stopped at my breakpoint, and the registration variable was the same value in the url.
But when I added the following method:
[HttpGet] [Route("car/{serial}")] public object GetCarBySerial(string serial) { return null; }
The first URL stops working and I started getting 500 - Internal Server Error . If I take the second method, the first method works again.
I do not understand why the second method breaks the first.
Can someone please explain this to me?
source share