开发者

how to map a new controller with a directory to get views

开发者 https://www.devze.com 2023-01-16 04:23 出处:网络
i am new to asp.net MVC , i have created a new controller name \"PersonController.cs\" and a new view folder \"Person\" ,

i am new to asp.net MVC , i have created a new controller name "PersonController.cs" and a new view folder "Person" , now the problem is person controller searching view only in "Home" and "Shared" directory not in Person Directory any answer?

Error : The view 'Reject' or its master was not found. The following locations were searched: ~/Views/Home/Reject.aspx ~/Views/Home/Reject.ascx ~/Views/Shared/Reject.aspx ~/Views/Shared/R开发者_StackOverflow社区eject.ascx


Your link in the view your wanting to navigate from:

<%= Html.ActionLink("Person Link", "Reject", "Person") %>

Your PersonController:

public ActionResult Reject()
{
    return View("Reject");
}

Hope this helps.


Make sure you have something like this in your Global.asax file (usually called in RegisterRoutes):

routes.MapRoute(
            "Default",
            "{controller}/{action}",
            new { controller = "Home", action = "Index" }
        );

Also you must have an action named Reject in the Person cotroller.

0

精彩评论

暂无评论...
验证码 换一张
取 消