MVC 4 Web API Areas 404 Error: "The controller for the path '/ Jobs / Send' was not found or does not implement IController."

I have a problem that drives me crazy.

I have an MVC 4 WebAPI application that defines several areas.

The send controller for my job pane (SendController.cs) is defined as follows:

namespace TargetAPI.Areas.Jobs.Controllers
{
    public class SendController : ApiController
    {
        [HttpPost]
        public HttpResponseMessage Index(SendRequest req)
        {
            try
            {
            //blah blah
            }
            catch (Exception ex)
            {
            //blah blah
            }
        }
    }
}

My job registration area (JobsAreaRegistration.cs) is defined as follows:

namespace TargetAPI.Areas.Jobs
{
    public class JobsAreaRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get
            {
                return "Jobs";
            }
        }

        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "Jobs_long",
                "Jobs/{controller}/{action}/{id}",
                new { action = "Index", id = UrlParameter.Optional },
                new[] { "TargetAPI.Areas.Jobs.Controllers" }
            );
        }
    }
}

My RouteConfig.cs says:

namespace TargetAPI
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                 name: "Default",
                 url: "{controller}/{action}/{id}",
                 defaults: new { controller = "Home", 
                     action = "Index", id= UrlParameter.Optional },
                 namespaces: new string[] { "TargetAPI.Controllers" }
            );
        }
    }
}

When I run the route debugger, I get: My route debug
(source: boomerang.com )

But when I try to post a Job / Submit message, I get:

The controller for the path '/ Jobs / Send' was not found or does not implement IController.

I tried so many iterations and combinations, I feel dizzy. Any ideas?

Thank!

+5
3

( MapHTTPRoute ), API MapHttpRoute, MapRoute, ( ):

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );

        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );

    }

{action}, , put HTTP-: Get, Head ..

+1

, : _ViewStart.cshtml _Layout.cshtml,

0

All Articles