I am in need of how the correct way to do this.
- I can not use forms authentication
- A user will "login" or confirm identity based on a value
I need to walk the user through a series of pages like so
- Contact/MailAddress
- Contact/Phone
- Contact/Email
- Contact/Summary
- Questionaire/Question1
- Questionaire/Question2
- Questionaire/Question3
- Questionaire/Summary
- Final/Certify
- Final/Review
I plan on using Session to hold the data but I'm having trouble figuring out how to pass the values to other views and how Redirect to other pages.
Any help will do...
Lets say you have some models like this
and you want to persist this model from view to view and action to action. In you controller you can create 2 actions. one for your first view and one for your second
Controller
in the first action
ContactAddress
you create a new blank model and pass that in to your viewContactAddress
. In that view you can set TempData["currentModel"] equal to the model you are passing in. This will stay in TempData for 1 post back to the server. You dont need to do this on the first page since it's blank anyway but i'm doing it to save time.View ContactAddress
you'll notice in the controller code that the Post Action for
ContactAddress
is setting a varcurrentModel
equal to what is in TempData["currentModel"] which was set in theContactAddress
view. Before you do a redirect to the next actionContactPhone
setTempData["currentModel"]
back to the model you are building and use it in the next action.You do have the option of adding the Model as a parameter to each action and passing the
currentModel
object likeits up to you really. this is not a foolproof way. page refreshes and back and forward buttons could clear out everything that was entered. Storing the information in
Session
or actually saving the data in a database might be more optimal.I advise against doing what you are attempting to do by logging in with session but what you are looking for is:
and