Asked by:
Issue handling custom 404 Error

Question
-
User1769015664 posted
My MainPage.pasx has 2 button (Button1, Button2). First button to open up a pdf document and the second button to load a modal popup.
When Button1 is clicked, I get a 404 Error (404.aspx) in a new tab when a pdf document is loaded in a new tab (Response.Write("window.open('../Docs/MyDoc.pdf', '_newtab');"); and this 404.aspx gets closed when a button is click which takes me back to previous tab which is MainPage.aspx (OnClientClick="window.close(); return false;). So far, so good.
<asp:Button ID="btnClose" class="aspButton" runat="server" Text="Close this page" OnClientClick="window.close(); return false; history.go(-1);"></asp:Button>
Now, I click on Button2 to load modal popup. It brings up 404 Error page 404.aspx replacing MainPage.aspx. From here, How do I get back to previous page which is MainPage.aspx?
Saturday, October 31, 2020 3:13 AM
All replies
-
User475983607 posted
We don't know if there is a bug in your understanding or code. Share the code that reproduces this issue.
Keep in mind, opening a new tab breaks the browser history. Opening a model is not tracked in browser history.
Saturday, October 31, 2020 10:47 AM -
User1769015664 posted
What's the best way to get back to the page where I clicked on button that failed to open up the modal popup?
The button for the Modal Popup is in Master Page.
Sunday, November 1, 2020 4:49 AM -
User1535942433 posted
Hi NJ2,
Accroding to your description,you could use history.back() or history.go() to go back the master page.
More details,you could refer to below article:
https://developer.mozilla.org/en-US/docs/Web/API/History/back
Best regards,
Yijing Sun
Monday, November 2, 2020 7:05 AM -
User1769015664 posted
It doesn't work...
Like mgebhard said earlier, opening a new tab loses the history and that's the issue I am having.
Monday, November 2, 2020 9:22 PM -
User475983607 posted
Like mgebhard said earlier, opening a new tab loses the history and that's the issue I am having.No. History is NOT lost. Opening a new tab breaks application history. The new tab gets its own history timeline while the original tab has its own history timeline.
Do not open a new tab. See the following for managing history when the HTML is modified by JavaScript.
https://developer.mozilla.org/en-US/docs/Web/API/History_API/Working_with_the_History_API
Monday, November 2, 2020 11:04 PM