I have an ApiController called MediaController, with routes mapped to methods via the [Route] attribute. For example:
[Route("v1/libraries/{libraryKey}/media"), HttpGet]
public ResponseObj Index(string libraryKey)
{
...
}
These routes are registered in my WebApiConfig.cs via config.MapHttpAttributeRoutes();
The problem I'm running into is that the routes for this specific controller (all others are fine and unaffected) will sometimes randomly stop working all together, and attempting to go to one triggers a error with the following message
{
"message": "No HTTP resource was found that matches the request URI 'http://localhost:8100/v1/libraries/libraryKey/media'.",
"messageDetail": "No route data was found for this request."
}
The only way I've found to (temporarily) fix this is to completely remove the git repository for the project from my computer, and re-download it. I don't know why this works because there are no noticeable difference in the files before and after the deletion.
Managed to figure out the cause of this. We had a rogue .dll file in the project's bin directory (which was being ignored by git, hence why it looked like there were no file differences and deleting the whole repo worked as a temp fix) being referenced by a separate project, which in turn was referenced by the main project.
This .dll included a controller with the same name (MediaController
), but difference routes, and so some unknown circumstances would cause that controller's routes to register in place of the intended main project's MediaController
routes.