[RESOLVED]MVC web api routing issues

This is driving me mad i cant understand why it wont work.

The MVC project is split into areas and in one of the areas registration there is

        public override void RegisterArea(AreaRegistrationContext context) 
                new { controller = "API" });
                new { controller = "Dashboard", action = "Index", id = UrlParameter.Optional }

The bottom one works fine its just the api one that doesnt work.

I have this Api Controller

    public class APIController : ApiController
        public int apiTest()
            return 5;


and on a webpage this js:

        url: "/API/apiTest",
        data: "",
        type: "GET", dataType: 'json', async: false,
        success: function (data)
        error: function () { alert('ajax error'); }

When i do something to run that javascript it tries to communicate with the server with url : 
http://localhost:53531/API/apiTest    with the response is 404.

There is no other routes set up in the project except for the ones above, there is only 1 area and nothing set up at the root level (outside any areas).



I’ve found the problem now, there was another route elsewhere in the project after all that it was matching to before getting to the one i wanted it to match to.

Hi Puma613,

If you have the issue about Web API, I suggest that you should post it to the
Web API forum

There is a link about Web API that may benefit you:

# Configuring ASP.NET Web API 2


Best Regards


Leave a Reply