简体   繁体   中英

How can I hold data through multiple Web pages

Starting at WebPage1, the user enters some data into a textbox and performs a search based on that search data. Then the user navigates away from WebPage1 to WebPage2 via a link.

How can I maintain their original search data when the user returns to WebPage1?

The user does not want to see the data in a query string. However the data is not sensitive, and any data from the client will be handled before processing.

We are using C# Mvc framework with Razor.

I have been trying to Post the entire model each time rather than using Get requests. However, this is not working well and does not follow a simple Post-Redirect-Get pattern more like Post-Redirect-Post.

You can use sessions to pass data from one webpage to another until you close the browser here is an example

//assuming the method below will return list of Products

var products=Db.GetProducts();

//Store the products to a session

Session["products"]=products;

//To get what you have stored to a session

var products=Session["products"] as List<Product>;

//to clear the session value

Session["products"]=null;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM