views:

329

answers:

5

Hi

I have an issue where the screen goes white for a millisecond on a redirect when rendering the new page.

This causes the screen to flicker and annoys me so.

I have had a little scoot round the web and have found this IE solution which works on IE however it does not on chrome or FireFox.

<meta http-equiv="Page-Enter" content="blendTrans(Duration=0.0)" />
<meta http-equiv="Page-Exit" content="blendTrans(Duration=0.0)" />

Plus I'm sure using this method will have some knock on effects on update panels and Ajax controls.

Is there a way of setting the server to render the full page before giving it the client so not to have this white millisecond that works for all browsers.

Any ideas will be welcomed.

+1  A: 

By default the server will buffer the complete response before sending it. The "white" will be a result of the content of the HTML possibly its size. Use a tool such as firebug or IE Developer Tools (my preference is Fiddler) to examine the generated content. At a guess you have some very large ViewState.

AnthonyWJones
view state does not seem to affect this some pages have one line some have ten.
Paul
@Paul: Ok what makes this flicker different from normal web navigation flicker we've all come to tolerate when using browsers?
AnthonyWJones
+2  A: 

The MSDN examples recommends to set

Response.BufferOutput

before calling

Response.Redirect("http://www.mydomain.com/default.aspx");

You may also want to try to use

Server.Transfer("default.aspx", true);
Filburt
Sadly non of the above have solved the issue
Paul
Reading http://stackoverflow.com/questions/224569/server-transfer-vs-response-redirect one would expect that Server.Transfer should resolve any issues with the browser.
Filburt
To add to Filburt's comment, no redirect occurs at all when you use Server.Transfer, so it's impossible for flickering to occur due to a redirect.
Andy West
Yes, but when using Server.Transfer, the browser's address bar will show the original page (instead of the page they were transfered to). Maybe that's not what the OP wants.
Gabriel McAdams
@Gabriel: As far as i understood the OP, any solution that solves the flicker would be acceptable.
Filburt
@Filburt: When is that ever the case? There are always other effects that you must consider. Never code with tunnel vision.
Gabriel McAdams
A: 

Probably best to do it on the client side. For example, you could have a div that covers the entire page and fades out once the DOM has been fully put together. In jQuery, something like this:

$(document).ready(function() { $('#overlay').fadeOut(); });

From a UX perspective though it might be a little disconcerting. I actually prefer a little bit of flicker so I know things are happening.

Pike65
nice suggestion but that would cover the page in a solid colour and look stranger than the fliker, I am tring to achieve a seemless flow between pages. the changing content will indicate things changing.
Paul
+2  A: 

What you're seeing is a normal occurrence. Here is what happens during a redirect:

  • The server sends a response to the browser (redirects are done on the client side).
  • The browser loads the response, sees that there is a redirect and stops the page load
  • The browser loads the new page

The meta tags you are using are IE only, and will not effect any other browser. The only things that will remove the flicker all together will be one of the following:

  1. You said that the redirect occurs when the user clicks on a button or on a grid row or something. If this were to trigger a change to location.href instead of a post-back, then the user would not see the browser flicker.

  2. Use Server.Transfer (this will result in the browser's address bar showing the old page instead of the new page (a redirect will change the address bar). This will only work if you are redirecting the user to a page on the same server.

  3. Send an HTTP 301 response (Moved Permanently). Tis will remove the flicker, but use this method with caution. It has other effects (it may effect search engine rankings).

To do #3, use this code on the server.

Response.StatusCode = 301;
Response.StatusDescription = "Moved Permanently";
Response.AddHeader("Location", "NewLocation.aspx");
Gabriel McAdams
+1 from me ... shame, your answer wasn't accepted.
Filburt
A: 

Is there a way of setting the server to render the full page before giving it the client

short answer: no. that's how a web browser works.

even with the fastest possible servers (using statically cached pages as you describe them), you're only decreasing the average "white" time, not eliminating it all together. as you're seeing with IE, that default page transition is part of the browser code, not something the server-side gets control over. if you write your own browser, you can write it to wash black, wash white, or hold the transition until the entire page is loaded, like IE does.

as other people mention, getting your page size down will decrease the "white" time. this time is not only the time the server takes to generate the page, but also all the network travel time for the page, images, javascripts, css, etc. that's why you can never fully get rid of it - only hide it using browser tricks.

and i'm not talking about "client-side" anything. that won't work. the "client-side" code isn't even downloaded, much less running, when the browser decides to white-wash the canvas. it's kind of a standard part of "the internet" that everyone just gets used to; it wasn't designed to be a slide show viewer or a graphically perfect renderer. unfortunately, if you care about transitions that much, HTML is probably not the right medium for your work.

ifatree