Faced the problem of saving information when opening new pages in an ASP.NET project.

I fill the xml-file with data that the user clogs into text boxes. And then they are already written from xml into the table, but this is not the point. I take the first 3 fields from 3 other tables. That is, I go through a button on a new page. I click in the table the line I need and read the line ID. But at the same time, every time I go to a new page, then this ID will be erased.

And there would be nothing terrible if there were such 2 fields. I would send a simple ID reader to redirect to a new page. The way is dreary, but I would keep the data. But the problem is that the fields are 3 and I lose 1 of the ID on any one.

Is there any easier way to save the data on the page, regardless of my transitions while I read the rest of the IDs? Thanks for the answer in advance. If something is not clear explained, ask. I will attach all the necessary code.

  • @Mike if you can help please in this matter. - Andrey
  • The topic is closed. Found an option. I just created a class in which I put together the necessary IDs and there they are stored normally. - Andrei
  • This is wrong, the topic is not closed. You have this “class” - static, that is, different users will write data there simultaneously. - Igor
  • I do not understand why it is impossible to abandon the XML file, if there is already a table in the database, then there is a base. It would be a classic web form: showed the form, recorded from the form in the database. But no, you definitely need to fly from Moscow to St. Petersburg through Vladivostok, create problems for yourself out of the blue, fight, win and think how good I am. - AK

2 answers 2

To save data when navigating between pages, you can use the Session object. You can also use the Cache object. And there is another option with TempData. The option with the session in your case would be preferable.

    Three options for transferring data between pages:

    1. Query - QueryString or form data;
    2. Session.
    3. Permanent storage such as a database.

    For you, I think the session is best suited - the Session property exists in both the controller (MVC) and the page (WebForms).