$window.location.href not working sporadically, it is working if I restart browser - angular-ui-router

My below code is stop working sporadically. It is not able to redirect to specific page (in this case landing page after successful login ). Using 1.2x Angular.
$window.location.href = (prefix ? prefix : '') + data.redirect;
It is not redirecting untill restarting the browser or clearing cookies and cache.
Even I added code to clear cookies and cache, still issue not resolved. Is it angular issue? When I debug the code, it is going to angular.js and from there it is redirecting back to application login page instead landing page of application.

Related

Browser back button doesn't work for Ajax Updatepanel click

I'm facing a crazy issue with in localhost vs production server.
Basically the issue is: browser back button doesn't have support for traversing in pagination, which works pretty fine in localhost. I am using Ajax update panel for pagination in grid view.
One more interesting stuff is: when I'm clicking on browser back button it appends a 404 URL, whereas I do not even have 404 page on my server.
the URL looks like:
http://www.example.com/404.aspx?404;http://www.example.com:80/domain-abcd/
I could able to travel all the pages in localhost and browser back button is properly responding taking me back to the previous page in gridview.
I am using IIS 6.0 and for rewrite URL Intelligencia UrlRewriter.
For this purpose I use the code below upon page load
form1.Action = Request.RawUrl
Any ideas on how to deal with, and fix these issues?
Please view below links..
http://rchern.wordpress.com/2008/05/11/updatepanel-backforward-browser-navigation/
how can i get the same page with the click of back button of browser
Hope this will help you.

AJAX GET-request appears in URL bar after refreshing the page in Tomcat that gets restarted

My web app runs under Tomcat, it uses AJAX requests very intensively, and during the development process I have to redeploy the web app intensively too. After the redeployment I usually simply refresh the page knowing that the user session is dropped, but I always get to the scenario described below:
Go to some page, a really big page with many JS-scripts included, that actually makes those intensive AJAX requests.
Stop Tomcat or redeploy the web app.
Refresh the page.
Enter the credentials in the sign-in form to authenticate.
Suddenly get the last AJAX request response in the browser window and the AJAX request URL in the URL bar.
Wow... It looks strange for me that AJAX request URLs appear in the URL bar along with their response in the web page display area. This actually happens to Firefox and Chrome (haven't tested it in other browsers). Unfortunately, I cannot reproduce the same behavior in a simple page written from scratch. Frankly speaking, I don't really understand what happens to such requests and why do browsers "think" if AJAX requests/responses are entered in URL bar by user...
Your possible explanations or hints for such a strange behavior are very and very appreciated. Thanks!
(Perhaps it can help: All AJAX requests are performed with jQuery 1.4.2)
I'm very sorry, as I understood later, the question is not complete, because there was another pitfall I didn't mention, so no one couldn't answer the question in principle. The reason of the bug was hiding in the... <body onunload="..."> tag definition. That was quite unexpected, but that code contained some AJAX request that must be invoked when a user leaves the page. I only realized that the authenicating module (FORM, j_security_check) returned a response (HTTP 302) containing the Location header - so that was the reason why browsers did redirects.
The exact scenario was like that:
Open the page containing <body onunload="some_ajax_here">.
Log out the app using another tab so you could stay at the same page.
Refresh the page so some ajax could be invoked - this AJAX request is not now allowed because it's a secured part of the application (you get the forwarded content of the login page).
Enter the credentials and now oops you get to the result of some ajax directly in the browser window.
As the quick fix, and I hope the final one, I added another request following that AJAX request:
$.ajax({
async: true,
method: "GET",
url: document.location.pathname + document.location.search
});
So the HTML page script simply makes self-page request the last one - j_security_check returns the Location referring the last used HTML page, and the redirect works fine. Perhaps my explanation is not clear and may be not complete or even full of mistakes, but it looks like that in general. I'm very sorry once again, and thank you #ChristopherSchultz!

Stop Safari/Firefox from Cacheing my page

I'm using PHP(header) to send a user back to the home page of the website(which looks different, due to a cookie, then when the user first arrived).
Everything works fine in Google Chrome but in Safari and FireFox a cached version of index.php is shown instead of the updated version of the webpage.
If I hit refresh things look as they should, but I need a way to tell the browser to reload the page without the user having to hit refresh.
Try this...
http://smartcoding.wordpress.com/2009/01/28/php-force-no-cache-page-load/

Prevent IE8's agreesive caching

I am having an issue with IE8 and its caching behaviour.
If I hit the page index.html and then continue to hit it again I am servered a page from the server.
However if I hit the page index.html?ui=v2 then index.html then index.html?ui=v2 I am served the page from cache.
The problem is the querystring ui=v2 is used to set a cookie which dtermines the view to deliver. As the page comes from cache the cookies view mode is not updated and I am served the same content as displayed for index.html (with no querystring).
This is IE8 and below, no other browsers.
Keen for any input Ideally I do not want to update the meta or response headers.
Thanks in advancecokkies

Classic ASP Logout Process

I'm working on a web application developed classic asp. It has logout button on the top menu which basically does the following actions
Session.Abandon()
Redirect to Index.asp, where users can login again.
After logging off users return to index.asp. But if users click back button the browser, they go to previous page. I don't want this to happen. I want a message saying that they are already logged off.I have implemented following steps
1.Add Response.Expires=-1 and Response.CacheControl="no-cache" at the top of each page.
2.On each page i'm checking session object to see it is not empty. If empty i'm creating a message saying that they are already logged off and need to log in again.
Now when users click back button after logging off, instead off showing logged out message, i get "Web page expired" message on IE8. I see the same behavior when users click back button on some page while logged in.
Any ideas how i can implement this better.
Thanks.
You can't stop users pressing back. A common scenario to work around this is that POSTs target a server page that displays no output but redirects to a new location instead (where the results can be seen).
There are additional non caching declarations that sometimes help:
Response.Expires = 0
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
I did read some time ago (hence inability to find link) that setting an expires to -1 can cause some browser to ignore it rather than have it expire immediately.
Even adding these extra cache controls won't stop some browsers from caching some things some of the time. FF quite often ignores a forced cache reload by the user, so you are in the browser makes hands to a certain extent.
Regarding your "Web page expired" message, this is (as mentioned) the result of the browser trying to stop you from resubmitting POST data (and potentially duplicating what you last did). The best way to get around this, and solve a number of other common UI issues on forms is to POST back to the same page, then if/when the action is completed, using a response.redirect to the same page, maybe with a URL encoded message to say "all done successfully". This allows your users to refresh and helps with the back button issue as most browsers now don't store properly redirected pages in their history.

Resources