Redirect back to same application as if typing the URL in address bar? (Not a Postback)

StackOverflow https://stackoverflow.com/questions/23135215

  •  05-07-2023
  •  | 
  •  

Question

Silly question,

Is there a way to redirect an application back to it's self from a button or a hyperlink (without a simple postback), as if you were typing the application's url in the address bar for the first time?

The reason I ask is because I have an application with a parent web form and then Telerik RadMultiPage that renders each page (or web user control) one at a time. I do not have the option to use the "RenderSelectedPageOnly" property in this case because I want the user to be able to navigate between pages with the TabStrip.

On the very last page, I want the user to be able to start the application all over, as if visiting the URL for the first time. The application is session based and when landing on the last page, I clear all session variables (Personal Information). On the last child page, I have put a button with Response.Redirect("default.aspx", true); event. The problem is that previous pages contain if statements that basically listen for certain session variables and act accordingly.

When I run the Response.Redirect("default.aspx", true); on the last PageView, I get "object reference not set to an instance of an object". I know it's because of Session variables that no longer exists but this happens because all MultiPage views are still loaded on a postback.

Any way to just simulate typing a url in the address bar and hitting submit?

Was it helpful?

Solution

You can accomplish this very easily with javascript.

Javascript

function ReloadMe() { window.location = window.location.href; } 

HTML

<input type="button" value="Reload Me" onclick="ReloadMe()" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top