postback causes delay

W

wizard04

I have a drop-down list, populated from a database, a few text boxes,
and a few buttons on a page. The ddl is set to autopostback.

For some reason, whenever a postback happens (when an item in the ddl
is selected or a button is clicked) the page is processed immediately
and is sent back to the browser, but after the browser displays the
first 50-75% of the page, it stops for about 60 seconds before
displaying the rest.

As far as I can tell it's not a server problem, because I set
trace=true and the page was processed in less than a second. However,
the same thing happens in IE6.0 and Firefox 1.0.7 on my WinXP computer
and in IE5.5 on my Win2000 computer, so I'm not sure where the problem
is. The only client-side code is javascript to set the focus to the
first textbox: document.getElementById("tb_prefix").focus();
and the server-generated _doPostBack function.

Any ideas?
Thanks
 
C

clintonG

In ASP we used to solve this problem by setting Response.Buffer = true so
all controls and contents of the page would be processed before the page was
displayed. I suspect the is a control that is giving the Response object a
hard time. How are you populating the ListBox for example? Kill ViewState
and test the page and so on.


<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/
 
W

wizard04

I'm populating the listbox when the page first loads, when an item is
removed from the list (one of the buttons), or when an item is added or
updated (another button). I use a function as follows:

Sub doDataBind()

Dim ds As New System.Data.DataSet
Dim sql As String
Dim myDbConnection As OleDbConnection
Dim myDbCommand As OleDbCommand
Dim myDbDataAdapter As OleDbDataAdapter

sql = _
"SELECT * " & _
"FROM Customer " & _
"ORDER BY LastName, FirstName, UserName"

myDbConnection = New OleDbConnection(strConn_ReportCards)
myDbCommand = New OleDbCommand(sql, myDbConnection)
myDbDataAdapter = New OleDbDataAdapter(myDbCommand)

myDbDataAdapter.Fill(ds)

myDbConnection.Close()

lb_customers.DataSource = ds
lb_customers.DataBind()

End Sub

with strConn_ReportCards being the connection string to my Access
database.

I just tried turning off viewstate in the @Page directive, but that
didn't help.
 
C

clintonG

I meant to turn off ViewState just to see what can be observed. I see you
need to get out of the habit of using the * metacharacter with your Select
statement. Use the actual names of the fields to avoid a performance penalty
when hitting the database. What if your table has a bunch of fields? The
metacharacter will select each field in the table and must determine which
field will or will not be used in the rest of the query.

The rest of your code looks fine. Then, if the contents of the ListBox do
not need to be changed with each PostBack I would suggest learning how to
cache the contents of the ListBox. That should about do it other than the
last suggestion to dump JET and use SQL Server as performance is much much
much better. How many other pages may be hitting that same database at the
same time? JET is a monolithic file. All requests get processes single file
injun style which I hear is no longer nice to say but I sure wonder where
the saying come from :)

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/
 
W

wizard04

I decided to make a simple test first. The following code (only two
buttons) has the same problem:

<%@ Page Language="VB" ContentType="text/html"
ResponseEncoding="iso-8859-1" Trace="false" EnableViewState="true" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>test</title>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
If Not IsPostBack then
response.Write("Not IsPostBack<br>")
else
response.Write("IsPostBack<br>")
end if
End Sub
Sub doA(sender As Object, e As EventArgs)
response.Write("A Clicked<br>")
End Sub

Sub doB(sender As Object, e As EventArgs)
response.Write("B Clicked<br>")
End Sub
</script>
</head>
<body>
<form runat="server" id="theForm">
<asp:Button ID="btn_A" runat="server" Text="A" OnClick="doA"/>
<asp:Button ID="btn_B" runat="server" Text="B" OnClick="doB"/>
</form>
</body>
</html>
 
C

clintonG

I have no more clues. Maybe its time to see if there may be something
happening on the server. Try your test page in another application on the
same server for example. I'm stumped and I'm not a performance guru by any
means. The URLs I provided make for some interesting reading though. I have
a page that loads really slow myself and haven't figured out why yet. What
more can I say?

<%= Clinton Gallagher
 
W

wizard04

To summarize, and hopefully get some more help with this:

I've been having trouble with the response time of aspx pages after
they are posted back to the server (I'm using vb.net). So far, it
looks like a server problem; I'd have to get the server admin to fix
it, so it would help to have a possible resolution before I ask him
(this won't be one of his priorities, unfortunately).

When I first GET a page, it works fine. When it POSTs back to the
server, they are processed by the server just fine, but for some reason
the browser receives only 70-90% of the page immediately and then waits
60 seconds for the rest of the page. To remove as many variables as I
can, I've been using a simple page to test with (code posted below).
Note that, with the test page, the browser seems to wait 60 seconds
before receiving anything (the previous page is still shown until
then). Here is what I've determined through my testing:

- I get the same results on both my WinXP computer (with both IE 6.0
and Firefox 1.0.7) and my Win2000 computer (with IE 5.5).
- They work fine locally (on my WinXP computer).
- I get the same results with the files both inside and outside of the
web application folder.
- It's not a problem with the page being recompiled since it works fine
on the first GET.
- With tracing turned on, I've found that the page is processed in less
than a second, so the problem seems to be after it is rendered but
before it is received/displayed by the browser.
- The file sizes are not large; for the aspx test page below, the
asp.net version is 932 bytes and the html version returned from the
server is 486 bytes.
- I get the same results with viewstate enabled and disabled.
- I get the same results with response.buffer set to true and to false.
- I get the same results coding the buttons using the format <input
type="submit" id="..." runat="server" value="..." onServerClick="...">
instead of the <asp:Button ...> format.
- A recent problem I've had may be related: response.redirect("...")
causes IE 6.0 to wait about a minute before displaying the page,
however it works fine for my other browsers. Though I still don't know
what causes this problem, I got around it by using these three lines of
code instead:
response.redirect("...", false)
response.flush()
response.end()

Here is the simple aspx test page I've been using, with only two button
controls:

<%@ Page Language="VB" ContentType="text/html"
ResponseEncoding="iso-8859-1" Trace="false" EnableViewState="false" %>
<% response.Buffer = true %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>test</title>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
If Not IsPostBack then
response.Write("Not IsPostBack (" &
Request.RequestType & ")<br>")
else
response.Write("IsPostBack (" &
Request.RequestType & ")<br>")
end if
End Sub
Sub doA(sender As Object, e As EventArgs)
response.Write("A Clicked<br>")
End Sub
Sub doB(sender As Object, e As EventArgs)
response.Write("B Clicked<br>")
End Sub
</script>
</head>
<body>
<form runat="server">
<asp:Button ID="btn_A" runat="server" Text="A"
OnClick="doA"/>
<asp:Button ID="btn_B" runat="server" Text="B"
OnClick="doB"/>
</form>
</body>
</html>

Any insights are welcome!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top