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.
// Create a view model that fit your needs
public class PasswordRecoveryViewModel {
public int StudentId { get; set; }
// Other properties as needed
}
// Do something like this in your action
public ActionResult YourAction () {
var model = new PasswordRecoveryViewModel {
StudentId = 1; // Assign the ID as needed
}
return View(model);
}
Then at the top of your view you add this:
@Model YourNameSpace.PasswordRecoveryViewModel;
You will then have access to your student ID with @Html.LabelFor(m => m.StudentId)