Reputation: 12163
I am trying to create another controller for my Ajax handler - so now I have an AppController (The site controller) and an AjaxController (the Ajax request handler).
The problem is, that when I access http://LocalHost:82/Ajax , I get The resource cannot be found
. When I access http://LocalHost:82/Ajax/Index , it works.
The problem is the default routing, right? Here is my routing:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "App", action = "NewRequests", id = UrlParameter.Optional } // Parameter defaults
);
If you need more info dont hesitate to ask. Thanks!
Upvotes: 0
Views: 3078
Reputation: 19821
Your routing:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "App", action = "NewRequests", id = UrlParameter.Optional } // Parameter defaults
);
Declares that default action is NewRequests, so it is expected that your AjaxController would have [HttpGet] NewRequests actions. You can do that by,
[HttpGet]
public ActionResult NewRequests()
{
// ...
}
or
[HttpGet, ActionName("NewRequests")]
public ActionResult WhatEverNameOfActionYouLike()
{
// ...
}
Upvotes: 3
Reputation: 10347
Is there an NewRequests method returning an ActionResult in the Ajax controller? If not, this makes sense as your default action is NewRequests.
Upvotes: 2