so I have a Url Action
<a href="@Url.Action("Create","Teacher", new { createAndAssign = true, teacherID = Model.AccountID })">Create new teacher & assign to account.</a>
That passes in two routeValues: createAndAssign, and teacherID.
Now when I go to my Teacher/Create page, my URL is like so:
.../Teacher/Create?createAndAssign=True&teacherID=ea817321-5633-4fdc-b388-5dba2c4a728e
Which is good, I want this. Now when I POST to create my teacher, how do I grab createAndAssign and teacherID value?
You can set the Querystring value in a hidden variables in the form and render in your GET action method and accept that in your POST action method.
View rendered by your
GETActionand now have a
teacherparameter and createAndAssign parameter in yourHttpPostaction method so that it will be available when you submit the form.If your view is strongly typed (which is my personal preference), it is quite easy,
and in your strongly typed view,
And in your
POSTaction