0

I am my first site with mvc 4, site uses heavy async requests and so far they are manageable, basically this is a page which display the records from DB in a grid and allow users to filter them based upon selection from some drop downs which make these requests.

Now the business requirement points to update URL when a filtration occurs so that users can share the filtered records via copy pasting URL, I am wondering if there is a way to achieve it like how instagram show's an image on click in a model popup and also updates the URL so user can share it and so does twitter when navigated through home to notifications.

Any suggestions would be highly appreciated. Thanks in advance.

foo-baar
  • 1,076
  • 3
  • 17
  • 42
  • 1
    search reveals http://stackoverflow.com/questions/824349/modify-the-url-without-reloading-the-page – whatever5599451 Sep 12 '14 at 17:39
  • @whatever5599451 : these are nice answers but consider scenario when user stores this url and next time makes an request to the page how will backend method read these value ? – foo-baar Sep 12 '14 at 17:48

1 Answers1

2

Instagram uses the Javascript History API to change the URL via javascript, without a redirect. Take a look https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history

// Suppose http://mozilla.org/foo.html executes the following JavaScript:
var stateObj = { foo: "bar" }; history.pushState(stateObj, "page 2",
"bar.html"); This will cause the URL bar to display
// http://mozilla.org/bar.html, but won't cause the browser to load bar.html 
// or even check that bar.html exists.

For an MVC-friendly js library, you can use History.JS http://balupton.github.io/history.js/demo/?state=2

Dmitry Sadakov
  • 2,128
  • 3
  • 19
  • 34
  • these is a nice solution but consider scenario when user stores this url and next time makes an request to the page how will backend method read these value ? – foo-baar Sep 12 '14 at 17:54