asp.net mvc - Ajax calling Area Controller -
i trying call controller ajax,but getting
failed load resource: server responded status of 404 ()
the ajax calling admin view admin controller.i can view admin page, unable call getall() , getallusers() ajax or other method.
in startup
app.usemvc(routes => { routes.maproute("arearoute",template:"{area:exists}/{controller=admin}/{action=index}/{id?}"); routes.maproute( name: "default", template: "{controller=home}/{action=index}/{id?}"); });
in admincontroller
namespace project.areas.admin.controllers { [area("admin")] [authorize(policy = "adminonly")] public class admincontroller : controller { public iactionresult index() { return view(); } public admincontroller() { } [httpget("getall/{page}")] public iactionresult getall(int? page) { } [httpget("getallusers/{page}")] public iactionresult getallusers(int? page) { } }
}
ajax
@section scripts{ @await html.partialasync("_validationscriptspartial") <script> $(function () { $.ajax({ type: "get", url: "/admin/getall", traditional: true, success: function (view) { $("result").html(view) } }); $.ajax({ type: "get", url: "/admin/getallusers", traditional: true, success: function (view) { $("userresult").html(view) } }); }); </script>
}
Comments
Post a Comment