<p>I'm writing a simple photo album app using ASP.NET Ajax.<br>
The app uses async Ajax calls to pre-load the next photo in the album, without changing the URL in the browser.</p>

<p>The problem is that when the user clicks the <strong>back</strong> button in the browser, the app doesn't go back to the previous photo, instead, it navigates to the home page of the application.</p>

<p>Is there a way to trick the browser into adding each Ajax call to the browsing history?</p>

[{'answer_id': 29896, 'author': 'Espo', 'author_id': 2257, 'author_profile': 'https://Stackoverflow.com/users/2257', 'pm_score': 2, 'selected': False, 'text': '<p>MSDN has an article about <a href="http://msdn.microsoft.com/en-us/library/cc488553.aspx" rel="nofollow noreferrer">Managing Browser History in ASP.NET AJAX</a></p>\n'}, {'answer_id': 29897, 'author': 'James B', 'author_id': 2951, 'author_profile': 'https://Stackoverflow.com/users/2951', 'pm_score': 2, 'selected': False, 'text': "<p>Many websites make use of a hidden iframe to do this, simply refresh the iframe with the new URL, which adds it to the browsing history.  Then all you have to do is handle how your application reacts to those 'back button' events - you'll either need to detect the state/location of the iframe, or refresh the page using that URL.</p>\n"}, {'answer_id': 29918, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>The 3.5 SP1 update has support for browser history and back button in ASP.NET ajax now.</p>\n'}, {'answer_id': 29992, 'author': 'Darren Kopp', 'author_id': 77, 'author_profile': 'https://Stackoverflow.com/users/77', 'pm_score': 0, 'selected': False, 'text': '<p>For all solutions about the back button, none of them are "automatic". With every single one you are going to have to do some work to persist the state of the page. So no, there isn\'t a way to "trick" the browser, but there are some great libraries out there that help you with the back button.</p>\n'}, {'answer_id': 30414, 'author': 'entropia', 'author_id': 1182, 'author_profile': 'https://Stackoverflow.com/users/1182', 'pm_score': 0, 'selected': False, 'text': '<p><em>Info</em>: Ajax Navigation is a <a href="http://blogs.msdn.com/ie/archive/2008/07/14/ie8-ajax-navigation.aspx" rel="nofollow noreferrer">regular feature</a> of the upcoming IE8.</p>\n'}, {'answer_id': 3591659, 'author': 'balupton', 'author_id': 130638, 'author_profile': 'https://Stackoverflow.com/users/130638', 'pm_score': 4, 'selected': False, 'text': '<p><strong>Update: There is now the HTML5 History API (pushState, popState) which deprecates the HTML4 <code>hashchange</code> functionality. <a href="https://github.com/balupton/history.js" rel="nofollow noreferrer">History.js</a> provides cross-browser compatibility and an <a href="https://github.com/balupton/history.js/wiki/Intelligent-State-Handling" rel="nofollow noreferrer">optional</a> <code>hashchange</code> fallback for HTML4 browsers.</strong></p>\n\n<p>The answer for this question will be more or less the same as my answers for these questions:</p>\n\n<ul>\n<li><a href="https://stackoverflow.com/questions/3205900/how-to-show-ajax-requests-in-url/3276206#3276206">How to show Ajax requests in URL?</a></li>\n<li><a href="https://stackoverflow.com/questions/3460041/how-does-gmail-handle-back-forward-in-rich-javascript/3460269#3460269">How does Gmail handle back/forward in rich JavaScript?</a></li>\n</ul>\n\n<p>In summary, you\'ll definitely want to check out these two projects which explain the whole hashchange process and adding ajax to the mix:</p>\n\n<ul>\n<li><p><a href="https://github.com/browserstate/history.js" rel="nofollow noreferrer">jQuery History</a> (using hashes to manage your pages state and bind to changes to update your page). </p></li>\n<li><p><a href="https://github.com/balupton/jquery-ajaxy" rel="nofollow noreferrer">jQuery Ajaxy</a> (ajax extension for jQuery History, to allow for complete ajax websites while being completely unobtrusive and gracefully degradable).</p></li>\n</ul>\n'}, {'answer_id': 10233899, 'author': 'Nikita Koksharov', 'author_id': 764206, 'author_profile': 'https://Stackoverflow.com/users/764206', 'pm_score': 2, 'selected': False, 'text': '<p>You can use simple &amp; lightweight <a href="https://github.com/mtrpcic/pathjs" rel="nofollow">PathJS</a> lib. </p>\n\n<p>Usage example:</p>\n\n<pre><code>Path.map("#/page1").to(function(){\n    ...\n});\n\nPath.map("#/page2").to(function(){\n    ...\n});\n\nPath.root("#/mainpage");\nPath.listen();\n</code></pre>\n'}, {'answer_id': 17628783, 'author': 'Igor Alexandrov', 'author_id': 226925, 'author_profile': 'https://Stackoverflow.com/users/226925', 'pm_score': 0, 'selected': False, 'text': '<p>If you are using Rails, then definitely try Wiselinks <a href="https://github.com/igor-alexandrov/wiselinks" rel="nofollow">https://github.com/igor-alexandrov/wiselinks</a>. It is a a Swiss Army knife for browser state management. Here are some details: <a href="http://igor-alexandrov.github.io/blog/2013/07/11/the-way-to-wiselinks-1-dot-0/" rel="nofollow">http://igor-alexandrov.github.io/blog/2013/07/11/the-way-to-wiselinks-1-dot-0/</a>.</p>\n'}]
['https://Stackoverflow.com/questions/29886', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/373/']