0

I am writing a site on asp net core and all pages in it are presented in the form of partialview. Thus, I achieve a spa model without using angular and other frameworks. When switching partialview, I can change the url of the page using

window.history.pushState ("object or string", "Title", "/ new url");

But when I switch back in the browser, my url just changes to the previous one, and partialview does not change. I want to intercept this transition and call the desired presentation. Is it possible?

jps
  • 20,041
  • 15
  • 75
  • 79
  • Possible duplicate of [How to trigger change when using the back button with history.pushstate and popstate?](https://stackoverflow.com/questions/8038726/how-to-trigger-change-when-using-the-back-button-with-history-pushstate-and-pops) – Tasos K. Oct 21 '18 at 17:07

1 Answers1

0

I think window.onpopstate or window.onhashchange would be useful. In your case you're creating history by pushstate which fires the former one when this entry has changed or replaced.

Abhishek
  • 382
  • 1
  • 6