I am trying to move from one Model's view to another Model's view. I have a Person model and a BurnProject model. From my Person's Index view I have a "Select" link in which I would like for it to go the BurnProject's Index view. I have tried a couple of things neither have worked.
public ActionResult BurnProject()
{
//return View("~/Views/BurnProject.cshtml");
return RedirectToAction("Index", BurnProject);
}
答案 0 :(得分:1)
From my Person's Index view I have a "Select" link in which I would like for it to go the BurnProject's Index view
Why not create a link which navigates to the index action method of BurnProjectsController ?
So in your Person's index view, you may use the Html.ActionLink helper method.
@model Person
<h1>This is persons index view<h1>
@Html.ActionLink("Select","Index","BurnProjects")
This will generate html markup for an anchor tag which has href
attribute set to "BurnProjects/Index"
.
If you want to pass some data from the person's index view to your BurnProject index action, you can use another overload of Html.ActionLink
@model Person
@Html.ActionLink("Select","Index","BurnProjects",new {@id=Model.Id},null)
Assuming your Person entity has an Id
property(which you want to pass the value for) and your BurnProjects index action accepts an id param
public ActionResult Index(int id)
{
// return something.
}