0

I have following controller with attribute routing. While making AJAX request with some parameter to "FileActionDefault" action, I have get routing attribute instead of AJAX action request parameters.

[RoutePrefix("DocumentsManagement/FileExplorer"), Route("{action=index}")]

    public class FileExplorerController : Controller
    {
        public ActionResult Index()
        {
            return View(MVC.Views.DocumentsManagement.FileExplorer.Index);
        }
        [Route("FileActionDefault")]
        public ActionResult FileActionDefault(FileExplorerParams args)
        {
           //In "args", I have get routing attribute "FileActionDefault" instead of AJAX action request parameters 
        }
   }

Could you please provide some suggestion to get AJAX action parameters in "FileActionDefault" method.

Also find AJAX request details enter image description here

BALA MURUGAN
  • 1,825
  • 3
  • 16
  • 17
  • 1
    Please provide the javascript code where you call this method as well. – Developer Nov 14 '16 at 06:08
  • I have added AJAX request details at above – BALA MURUGAN Nov 14 '16 at 06:16
  • hmnn..interestng, this should work. I hope you have enabled attribute routing in your config. Just a try, decorate the method `FileActionDefault` with `[HttpPost]` attribute / just try specifying `[FromBody]FileExplorerParams args` – Developer Nov 14 '16 at 06:21
  • Replace `Route` with `HttpPost` attribute. If it still not working maybe using camelCase for your action instead of PascalCase may help. – CodeNotFound Nov 14 '16 at 06:55
  • Missing `HttpPost` attribute on action. – Nkosi Nov 14 '16 at 07:02
  • I have added HttpPost attribute, but its not working. Any other suggestions? Additional info: I have used MVC not WebAPI – BALA MURUGAN Nov 14 '16 at 07:07
  • is attribute routing enabled? – Nkosi Nov 14 '16 at 07:11
  • yes, pls refer following code block public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("Content/{resource}.axd/{*pathInfo}"); routes.MapMvcAttributeRoutes(); } } – BALA MURUGAN Nov 14 '16 at 07:20

0 Answers0