I’ve got 2 views: Question and Answer. From the Question View, Detail Action I wanna redirect to Answer View, Create Action, so I’ve placed:
@Html.ActionLink(Model.QuestionId.ToString(), "Create", "Answer", "Answer", new { id = Model.QuestionId })
and in Answer View:
public ActionResult Create(string id)
{
(...)
return View();
}
But the id in Create(string id) is always null. How can I pass this value properly?
You are using a wrong overload of the ActionLink helper. It should be:
which would generate
whereas you are using:
which generates:
I think that now it’s not difficult to understand why your anchor doesn’t work.