I am using an MVC 5 application with WebApi2 in the same domain. My problem now is how to handle 404 error in WebApi. I use routing in my WebApi.
[RoutePrefix("myapi")] public class MyApiController : ApiController { [Route("value")] public string myvalue() { return "value"; } }
Now I have a url "/myapi/value" that returns a string of values. The problem is that I requested "/myapi/value/bla/bla" or any URL that is not in my API, it returns a 404 error.
I tried this link http://weblogs.asp.net/imranbaloch/handling-http-404-error-in-asp-net-web-api , it applies only to the WebApi project, but not to the MVC + WebApi project.
Please, help. TIA
UPDATE:
Please read carefully !!!!
This will be the default page if you are not processing 404 in your WebApi. It includes your physical path.

source share