vendredi 20 novembre 2015

onhashchange event doesn't detect changes between "/Home/Index" and "/" - ASP.NET MVC3

I'm working in a ASP.NET MVC3 web app, and my problem is the following: I want to detect URL changes using:

window.onhashchange = function (event) { 
    //some stuff...
};

and it works perfectly... But, it works perfectly while in the url always appears:

'localhost:[port]/Home/Index'

or in some cases, url changes to:

'localhost:[port]/Home/Index#'

When the user changes the url (for example, he deletes '/Home/Index'), the pages is reloaded (the url is 'localhost:[port]/') but when user presses back button and back again to '/Home/Index' onhashchange event doesn't detect this change. Why? '/Home/Index' and '/' is the same?

Aucun commentaire:

Enregistrer un commentaire