RenderAction を呼び出す "Resume" ビューがあるので、履歴書にコメントを追加できます。コード:
@{Html.RenderAction("Add", "ResumeComment", new { resumeId = @Model.Id });}
したがって、上記のコードは、ResumeComment コントローラーで Add アクションを呼び出し、resumeId を渡します。Add (GET) メソッド内の ControllerContext.ParentActionViewContext.RouteData を見ると、次の 4 つの値が表示されます。
PL <- which is resume category
954 <- resume id
Resume <- Controller
Edit <- Action, because I am adding comments on the Edit page in the resume.
The problem that I have is that I am loosing resume category (PL) and resume id(954) when I post (add a comment). Here is my ResumeComment form:
@using (Html.BeginForm("Add", "ResumeComment"))
{
...
<input type="submit" value="Add Comment" />
..}
So this form will call Add (Post) method in the ResumeComment controller when sumitted. Here is my add method:
[HttpPost, ActionName("Add")]
public ActionResult Add(ResumeComment resumeComment)
{
.....
}
I am not able to access ControllerContext.ParentActionViewContext.RouteData at all, it is null. I am however able to access ControllerContext.RouteData but when I look at the values I only see "ResumeComment" and "Add" in there and that is it. How can I preserve the resume category and resume id?