我可以像这样将对象传递给视图吗? 我这样做时遇到404错误。
在我的MoviesController中,我有:
[Route("movies/movieDetail/{id}/{name}/{x}")]
public ActionResult movieDetail(string id, string name, Movie x)
{
//return Content(@"This is movie with id: " + id + @" and name : " + name);
return Content(@"This is movie with id: " + x.Id + @" and name : " + x.Name);
}
在索引视图中,我有:
@model List<Vidly.Models.Movie>
<tbody>
@foreach (var movie in Model)
{
<tr>
<td> <a href="/Movies/movieDetail/@movie.Id/@movie.Name/@movie"> @movie.Name </a></td>
</tr>
}
</tbody>
我的想法是,当我点击链接时,它会将我带到movieDetail,但当我这样做时,我会得到404.
有人可以解释一下这是为什么吗?