I have one ASP.NET MVC application which also has areas in it.
For short URL I have set route all actionmethods with short URLs in RouteConfig of areas like below.
//admin dashboard having short URL admin/dashboard
context.MapRoute(
"admin_dashboard",
"admin/dashboard",
new { area = "admin", controller = "admin", action = "dashboard" }
);
//student list having short URL admin/studentlist
context.MapRoute(
"student_list",
"admin/studentlist",
new { area = "admin", controller = "students", action = "List" }
);
//new student having short URL admin/student/new
context.MapRoute(
"student_new",
"admin/student/new",
new { area = "admin", controller = "students", action = "RegisterStudent" }
);
//edit student having short URL admin/student/id
context.MapRoute(
"student_edit",
"admin/student/{id}",
new { area = "admin", controller = "students", action = "RegisterStudent" }
);
As you can see I have defined short URLs for all the actionmethods and it is also working fine except the last two which have calling the method but returns blank view.
[Route("admin/student/{id}")]
[Route("admin/student/new")]
public ActionResult RegisterStudent(string Id)
{
....mycode
return View("RegisterStudent", mymodel);
}
The problem is it is calling the method without any error, but it is not returning the view. It returns the blank view. Why does this happen, did I make any mistake?
If your request is going to your action method, then there is no problem in routing. If your action is returning a blank View
then, there must be some problem with View
itself.