0

I am creating an app that I need to pass a value around, this will be equivalent to a username, where the first part of the wizard will create the username and this username will be passed between views to fill out the rest of the form.

What are the best practices to pass this value around, is it pass it as part of each view form submit (make it a hidden field) of each form or what is the best way. Storing this in the session is not idea as I do not want to lose the value after session time out.

I just like to understand what the best practices are. I also would not like this value to be visible to the user (not part of querystring)

EDIT:

for clarity, i already use database to persist the state of my data, I am talking about passing ONE field around so that I can load/save rest of the data to the same ID.

1 Answer 1

1

If you're dealing with a complex graph and/or you want it persistent, you would either need to use a database-backed Session or just create your own database entity and update it between stages of the wizard.

Hidden fields or even cookies are possibilities, but they'd only be reasonable to manage for small amounts of data, and you mentioned you don't want to expose the data to end users. You could just encrypt the serialized object containing your wizard state, kinda like view state does, and pass it via a hidden if you don't want to write persistence for it. But since you did say you don't want to lose state between sessions, maybe it'd be most sensible to just store it in the database as I mentioned.

No hard and fast rule, just enumerate your requirements and go for it.

Sign up to request clarification or add additional context in comments.

2 Comments

I already use a database to persist all my data, I am talking about ONE field that want to pass around during the creation so for each view I can use that ID to look up the rest of the data.
I see. Then yeah, I'd just persist it using a hidden. I'd just make sure to write some validation to make sure the record they reference in the hidden is their own. It's unlikely that someone would steal someone else's ID, but never leave that sort of thing to chance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.