C#C
C#14mo ago
darkdendrin

What is best practice to pass model information between razor pages?

I have a simple app, where I have 3 Razor Pages. One is a form, next is a form confirmation and then lastly either form successful or form failure. The form data contains sensitive information, so passing it in as a query string parameters is not feasible. I would like the information only persist as long as the user’s browser is open.

I see two possible options, TempData and Session. But I am not sure what would be more appropriate or best practice. Microsoft docs recommend Session, but wanted to get a read from other devs on this.

Also, I only plan to save the model to the dbcontext in my second razor page using EF linq methods, not sure if that has an impact on the decision.
Was this page helpful?