currently work on mvc with using razor, where wish to assign my session value to model, may i know how it can be done? did some research but din see any.
to display the ID of student that applying for password recovery, and save the studentId in session in order to further process and show in password recovery form
in view
@Html.LabelFor(m => m.StudentId)
@Html.DisplayFor(m=> m.StudentId)
when i wish to assign my session into m.StudentId, is there anyway can solve it?
in controller
Session["StudentId"] = passwordrecovery.StudentId;
If I understand you right, the best way would probably be to create a viewmodel, to which you assign the StudentId in your action before you return the view, rather than keeping the value in the session. You then pass the viewmodel to the view, and will have access to the StudentId in your view when creating your form.
Then at the top of your view you add this:
You will then have access to your student ID with
@Html.LabelFor(m => m.StudentId)