Class Student {
String Name {get; set}
//Extended pr开发者_高级运维operty of the student
School Shooling {get; set;}
}
public StudentControlelr ()
{
public SchoolInfo (int? ID)
{
Student s = StudentRepository.GetStudentByID(id)
Return View ("Schooling/Index", s.Schooling);
}
}
for some reason i have to make this view as a shared view
// Views/Shared/schooling.ascx
Return View ("Schooling", s.Schooling);
This works but why not if its in a different view folder it won't work? Am I missing some thing here?
Please note that ASP.net novice.
Kind Regards Vinay
You can redirect to the action:
return RedirectToAction("Action", "Controller");
The only issue here is that you cannot pass a model, but there are a couple ways to get around this:
Pass parameter and get the model upon load
return RedirectToAction("Action", "Controller", new { id = 1});
Pass the model using TempData
TempData["MyModel"] = s.Schooling;
return RedirectToAction("Action", "Controller");
This will work but a better solution would be to redirect to a different action:
return View ("~/Views/Schooling/Index.aspx", s.Schooling);
Note: You will need to change .aspx to your views extension if you are not using ASPX Views.
精彩评论