Question: I have following code in aspx 

```
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" nherits="test" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server"></head>
    <body>
         <img src="images/loading_anim.gif" />Please wait...
      </body>
    </html>

```

In test.aspx.vb

```
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
......Do some processing here .
Response.redirect("Next.aspx")
End Sub

```

Code Behind I do some processing in Page\_load method and redirect to other page but it might take some time so I want to show user loading image.But it shows that after page\_load is completed.How to handle this ?

Answer: 
I will suggest that you use a generic handler (ashx) and use un-buffered response. For example:

```
public class Handler : IHttpHandler 
{

    public void ProcessRequest (HttpContext context) 
    {
         context.Response.BufferOutput = false;
         context.Response.Write("<html><head></head><body><img src=\"images/loading_anim.gif\" />Please wait...</body></html>"  
         context.Response.Flush();  

         // do your processing
         ...
         // redirect 
    }
 ...
}

```

Yet another way to first show image on the client side (using java-script) and then do redirection (or post) from client side.
I don't think it will work because always the server side code works first, then only HTML rendering starts. Better option will be using Ajax.

More details here : [ASP.NET Integration with IIS 7](http://learn.iis.net/page.aspx/243/aspnet-integration-with-iis-7)