Why page_load is called twice in my web application? - visual-studio

I have already gone through some of the posts in many websites regarding page_load being called twice but my problem is little bit different from those.
My problem is with the landing page of my web application.
Initially in my website page_load for the landing page was getting called twice every time when it is loaded. Since my application is an upgraded one (from VS 2003 to VS 2005/2008), I commented the "this.load" event in InitializeComponent. Now it works fine, when user first logs in, into my web application. But then, whenever user navigates to this page from any other page in my application, page_load gets called twice.
Does anybody have any idea about why this could be happening. I tried to track the call stack for this, but VS 2008 was showing that this was getting called from external code.
Also, I am using frames in my web application. I wonder if this problem has anything to do with frames.
Any help is deeply appreciated.
Regards,
Hari

Related

Persistant Chat Window? Like Facebook or OkCupid

I saw this question asked here 18 months ago, but without (a correct) answer: Window like facebook chat
Both Facebook and OkCupid have messaging windows which stay open even when you click to another page on their website. Literally the IM window (and friend list, on Facebook) don't so much as flash or "blink" as if they were reloading quickly. If you refresh the website (F5 or such) then the messages will disappear, at least for a moment.
The only thing I can think of is that the entire website never actually changes addresses, but just pushes the new URLs to your browser so it looks like the URL changed, but you never really left the same file.
How are they offering this persistent chat?
My guess is they are using something similar to qjuery-pjax:
https://github.com/defunkt/jquery-pjax
From their docs:
pjax works by grabbing html from your server via ajax and replacing the content of a container on your page with the ajax'd html. It then updates the browser's current url using pushState without reloading your page's layout or any resources (js, css), giving the appearance of a fast, full page load. But really it's just ajax and pushState.
This means clicking a link on the page will load only part for page and leave the chat windows untouched (no flicker). If you hit F5, the browser is initiating the refresh which will not use ajax/pushState. This causes the chat windows to flicker.

Primefaces Ajax response fail randomly

I am using p:datatable and on clicking of row (Command link) I am displaying a panel. Most of the time it is working fine but in regression testing some time it is getting hanged but request is going to ManageBean fetching all the data.
But it is not rendering the panel. This error has no specific pattern. I have put log in all possible place even in phaselistner lifecycle everything looks good.
I checked in firebug response is also coming. from server
I am using weblogic 10.3.6,primefaces 3.5 and internet explorer 9.x
Try putting in a component in the page where the data table lives. This displays Ajax events and alot more. Then compare the log output for when it succeeds against the output for when it fails. This may point to DOM as was suggested or somewhere else.

how does usatoday display URI for news docs?

I am developing a web app/message board in AJAX. Ive come to the part where I need to decide how to display threads.
Should I refresh a completely new page for each thread? Or load it via AJAX. Obviously, I want each thread to be crawlable, linkable, and saveable as a favorite in your browser.
Then I saw USAToday's website (www.usatoday.com/news). Its very interesting how they load the page through a popup window, change the URI, and keep the data in the background.
This is exactly what I want, but I don't know what they are doing.
Can anyone else decipher this or lead me down the right path?
My impeccable googling skills has led me to believe that the answer lies in pushState.
http://www.seomoz.org/blog/create-crawlable-link-friendly-ajax-websites-using-pushstate
Essentially, it appears they are...
using the HREF of the provided link to change the URI via pushState.
using AJAX to load the contents of the page accessed via the link.
on close, they most likely use data from the newly loaded page to figure out what section its was under(sports, entertainment, etc), and reload that page.

HTTPModule invoked on main page but not on sub-page

I am facing a strange error in MOSS 2007 running under Windows 2008. I have created a custom HTTP Module that fires on the application's OnAuthenticate event. It basically creates a custom cookie which is used by another application to authenticate the user, creating a single sign-on effect.
Everything went fine under the development server running Win2K3. However, on the staging server the following wierd things are happening:
a) The module seems to fire on the base page, i.e. https://conn.test.com/Pages/Default.aspx, however if somone goes into a sub-page directly like: https://conn.test.com/Operations/Pages/Operations%20Portal.aspx, it does not seem to fire.
b) The module gets fired from IE but not from Firefox or Chrome. The only difference between the two seems to be that a certain webpart loads and works in IE but does not seem to load or work in Chrome or FF.
Can someone help explain the behaviour of this. The HTTPMOdule overrides the AuthenticateRequest event of the application.
Sorry got this figured out. The problem is that the Init method of the event handler for OnAuthenticate works with privileges of the underlying ASP.NET user, but the main event handler delegate works with the credentials of the authenticated user.
I had written some code t log on to an Event Log and apparently this needs higher level privileges. This was the reason the module's delegate was firing but nothing was getting logged.
My guess is that the webpart on the main page ran with privileges of some other user who had the necessary access rights and hence things worked there. Since it does not work in FF or Chrome the module did not work in those browsers. Also the sub-pages do not have the webpart, hence directly going onto them, also causes the problem.
The issue got sorted after I added SPSecurity.runWithElevatedPriviliges around the logging code.

Web page expired message in browser

I am implementing a web application using ASP .Net and C#. One of the pages has a requirement that it always needs to be fetched from the server, rather than from the local browser cache. I have been able to achieve this.
We have a back button in the application, which simply invokes javascript:history.back() method. The problem is that when the back button is clicked to navigate to the page which is always to be reloaded from the server, the browser displays a "Web page expired message".
The intent here is to force the browser to reload the page rather than display the web page expired message.
Any help would be highly appreciated. Thanks a ton in advance.
You will probably need to change the implementation to make the browser load the URL explicitly:
window.location.href = 'http://....';
instead of invoking the back button, since the intention of the back button is to get the last page from the cache.
(If browsers would not act that way, they would re-send your form data multiple times when using the back button during a registration process or similar.)
You mean you want to control browser behaviour, which is not possible. I doubt you can solve it that way. You could set the expiration time to a small value (1 minute perhaps?) so that the page is still valid if one navigates back quickly.

Resources