Sunday, February 1, 2015

Page history solution for GET request in IE

Recently I was working in a Single Page Application using AngularJS. The problem I face in Internet explorer is that , “Particular view was not loading for respective user”. Let me explain the scenario.

As it was single page application, I used view to load page-let in main view window and data were coming in time of page loading (from service via controller).

Now , the problem was, when normal user  is log in one particular view was getting load. It’s fine and when admin is log in the previous view was loading again only in Internet Explorer.  It was working fine in Chrome and Firefox.

I made little search Google and tried few remedies like set no cache in code behind and HTML header too. Those tricks not worked for me.  I found that to make forcefully HTTP request using GET request we can pass unique parameter as parameter of url. I implemented the same.

$http({ method: 'GET',
url: '../UserHome/GetUserInfoById?randomId=' + new Date().getSeconds() });

Please have a look on parameter part of url, It’s simple , Just passing second of current data which will be unique (hopefully J)

Now, even Internet Explorer will perform fresh GET request to server.