c# - Application can't find view when using areas -
i experimenting areas , have ajax call calls action when trying return partialview says can not find it:
userarearegistration.cs :
public class usersarearegistration : arearegistration { public override string areaname { { return "users"; } } public override void registerarea(arearegistrationcontext context) { context.maproute( name: "user", url: "user", defaults: new { controller = "user", action = "createuser" } ); context.maproute( "users_default", "users/{controller}/{action}/{id}", new { action = "index", id = urlparameter.optional } ); } }
in user controller tried:
[routearea("user")] public class usercontroller : controller {}
the action:
public actionresult getusrform() { var model = new usermod(); return partialview("testuuu"); }
but still get:
the partial view 'testuuu' not found or no view engine supports searched locations. following locations searched: ~/views/user/testuuu.aspx ~/views/user/testuuu.ascx ~/views/shared/testuuu.aspx ~/views/shared/testuuu.ascx ~/views/user/testuuu.cshtml ~/views/user/testuuu.vbhtml ~/views/shared/testuuu.cshtml ~/views/shared/testuuu.vbhtml
what missing?
i faced same issue before when dealing areas , solved adding area name in ajax url
$.ajax({ url: 'users/user/getusrform', success: function (data) { // } });
the action
public actionresult getusrform() { var model = new usermod(); return partialview("~/areas/users/views/user/testuuu.cshtml"); }
Comments
Post a Comment