ASPX: redirecting, removing QueryString, but not creating history in browser

I am looking for a way to get rid of the page request and redirect to myself, but somehow save the querystring data. Example: http://www.test.de/somepage.aspx?id=abcshould be redirected to http://www.test.de/somepage.aspx. However, after the redirect, I want to get the parameters that were originally passed. And I do not want to have http://www.test.de/somepage.aspx?id=abca browser history.

What I have tried so far:

  • Response.Redirect(): Makes the correct redirect without creating a browser history, but I cannot save the settings.

  • Server.Transfer: Saves settings, but the browser URL does not change.

  • Create a client form "on the fly" and send it to onload: it works, a request is issued, the parameters are available through Request.Form, but it creates an entry in the browser.

The only thing I can think now is to save the parameters in the session, then redirect them, and then pick them up from there. But maybe there is another solution?

+3
source share
2 answers

As Pete mentioned, you can save your request parameters in a session and then call Response.Redirect to redirect to the second page

Session["id"] = Request["id"];
Session["param2"] = Request["param2"];
Session["param3"] = Request["param3"];
....
Response.Redirect(sameurl);

On the second page load, check if the querystring values ​​have disappeared. If they are, instead of reading the values ​​from querystring, read the values ​​from the session.

id = Session["id"];
param2 = Session["param2"];
param3 = Session["param3"];
...
+2
source

, , . , . . , Refresh ? .

URL-, , : http://www.test.de/somepage/abc

0

Source: https://habr.com/ru/post/1760529/


All Articles