Results 1 to 6 of 6

Thread: smoothing the end user's page performance [RESOLVED]

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    608

    Resolved smoothing the end user's page performance [RESOLVED]

    I have a process intensive asp.net page that takes up to two minutes to finish processing. It's a backoffice page that connects to different web services / API's, does some stuff and returns either success or error + error message, that gets displayed in order on a datagrid.

    I know I can't do the process faster, because the web services / API's are 3rd party. But I wan't to "smooth" the end user's performance.

    Is there anyway to get the datagrid "updated", so the end user see's the results of each connection to the API's? Instead of waiting until the whole page process, and then get the results. Is some kind of flush? or dump? I tryed response.flush() but it doesn't do anithing I can see.

    Thanks
    HoraShadow
    Last edited by HoraShadow; Oct 22nd, 2005 at 09:34 PM.

  2. #2
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: smoothing the end user's page performance

    Do not use any of ASP.NET's built in controls, instead, manually write a table using Response.Write and Response.Flush.

    Another thing you have to do is specify the column widths on the table in pixels for ALL columns, otherwise the end user's browser will wait for the whole table before it shows it. If you specify all the widths manually up front, most browsers will write the table as it receives it.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    608

    Re: smoothing the end user's page performance

    Thanks for your answer Lord_Rat!.

    I tryed your suggestion with a test page, but I couldn't get it to work. After 6 seconds it display the entire page. Instead of flushing segments.

    I used the debugger of vs2003 and IE6.1.

    This is de code I used to try this out is:

    VB Code:
    1. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.     Dim counter
    3.  
    4.     Response.Write("<table border=1>")
    5.     Response.Flush()
    6.     For counter = 0 To 5
    7.       wait(counter)
    8.     Next
    9.     Response.Write("</table>")
    10.     Response.Flush()
    11.   End Sub
    12.  
    13.  
    14.   Private Sub wait(ByVal cycle As Integer)
    15.   sytem.threading.thread.sleep(2000)
    16.  
    17.   Response.Write("<tr><td width=500>" & cycle.ToString & " | " & now & "</td></tr>")
    18.     Response.Flush()
    19.   End Sub

    What I'm missing for this test to work?

    Thanks
    HoraShadow
    Last edited by HoraShadow; Oct 21st, 2005 at 10:59 AM.

  4. #4
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: smoothing the end user's page performance

    Response.Write("<table border=1>")

    Change to :
    Response.Write("<table border=""1"" width=""500"">")
    Response.Write("<colgroup")
    Response.Write("<col width=""500"" />")
    Response.Write("</colgroup>")

    You don't have to specify a width on the TD elements themselves.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    608

    Re: smoothing the end user's page performance

    Thanks again for replying!

    I still can't get it to work. I must be doing something wrong, but I don't realize where, or what.

    The test code right now looks like this:

    VB Code:
    1. Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.     Dim counter
    3.  
    4.     Response.Write("<table border=""1"" width=""500"">")
    5.     Response.Write("<colgroup>")
    6.     Response.Write("<col width=""500"" />")
    7.     Response.Write("</colgroup>")
    8.     Response.Flush()
    9.  
    10.     For counter = 1 To 5
    11.       System.Threading.Thread.Sleep(2000)
    12.       Response.Write("<tr><td>" & counter & "</td></tr>")
    13.       Response.Flush()
    14.     Next
    15.  
    16.     Response.Write("</table>")
    17.   End Sub

    While the page process, If I right click and select view source, I can see the tr and td forming up. But it still doesn't display as it gets received. The code IS received, row by row, but not displayed. It gets displayed as soon as the page finishes rendering and gets dumped to the browser.

    The html code looks weird too. It looks like this:

    VB Code:
    1. [B]<table border="1" width="500"><colgroup><col width="500" /></colgroup><tr><td>1</td></tr><tr><td>2</td></tr><tr><td>3</td></tr><tr><td>4</td></tr><tr><td>5</td></tr></table>[/B]
    2. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    3. <HTML>
    4.   <HEAD>
    5.     <title>WebForm1</title>
    6.     <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    7.     <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
    8.     <meta name="vs_defaultClientScript" content="JavaScript">
    9.     <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    10.   </HEAD>
    11.   <body>
    12.     <form name="Form1" method="post" action="WebForm1.aspx" id="Form1">
    13.     </form>
    14.   </body>
    15. </HTML>

    The table gets dumped before anithing else. Maybe that's what's giving me issues?

    Thanks
    HoraShadow

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    608

    Re: smoothing the end user's page performance

    Resolved! Thanks!.

    The error I was having, was that the browser doesn't display the table flushed untill it receives the /table. The browser displays complete tables, not just pratial tables.

    Thanks a bunch Lord_Rat!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width