Is it possible to save and restore a complete aspx

2019-07-24 23:14发布

问题:

Our customers have this requirement:

  • A search page should be shown in a modal dialog (iframe) when the user clicks the search icon on a form
  • The user can search, browse his search results, and select a record
  • Now the modal dialog hidden and the user views the record
  • When the user clicks search icon again, the modal dialog shows up again

Now the part for my question:

  • When the user leaves the current page, and returns on the page after a few minutes and presses the search icon again to continue with his search, he should see the same page as where he left before.

I prefer to just save the complete page and restore it when the user wants to view the search page again. But I don't know if that is possible..

I don't really want to save all the search filters, and do the search again when the user goes to search page, because there are > 100 search filters and the search can take while also.

It is a hard requirement from the customer that he should be able to continue with his search, and should not start over again every time he goes to the search page again.

Thanks for all suggestions on this.

回答1:

It sounds like you could use .NET's @OutputCache page declaration with the VaryByParam attribute set (if the search params are pass through the querystring, at least.)



回答2:

I would come up with some sort of custom cache mechanism to store search results on the server. when the user submits a search, results are stored in the cache and a key is returned to the page. then when the user clicks the button to re-view the results, retrieve the results from the server using the key.



回答3:

Why don't you save the search results to a session or viewstate variable?

If I was in your position (and could not save the search results to a session variable) I would:

  1. Make the modal dialog its own page.
  2. Download the page on the server (server connects to the modal dialog page and downloads the contents).
  3. Store the downloaded page somewhere (probably the session, but maybe the database or in the file system).
  4. Add an iFrame to the modal dialog (make sure you add the name field or it will not work in FF).
  5. Set the source of the iFrame in the modal dialog to the saved search results.

It should be noted that this solution will have issues if the search results use server side, browser dependent controls (controls which return different HTML based on the browser type indicated at the server).

If you want, the iFrame can be replaced with a div if you set the div's inner html to the inner html of the body tags on the saved page.

I believe there is also a feature built into ASP which will get the rendered text of a page, but I do not remember what it is called.