超过响应缓冲区限制传统的ASP错误

问题描述:

我没有关于响应缓冲区限制一些研究超越错误,才知道我应该在我的ASP请使用Response.Flush()<%将Response.Buffer =假%>码。超过响应缓冲区限制传统的ASP错误

我在我的代码中使用了这个解决方案。这是在页面顶部是这样的:

<%@LANGUAGE="VBSCRIPT" %> 
    <%Response.Buffer = false%> 

而且在循环中,我使用的MoveNext之前Response.Flush()是例如:

Response.Flush()  
    rsCustomer.MoveNext 

但我现在面临的问题是,加载页面需要花费太多时间。那么还有其他解决方案吗?

唯一的解决办法是增加缓冲区限制的大小。在我的配置文件中,我没有任何与bufferesize有关的代码。

更新:代码示例:

table border="0" cellspacing="0" cellpadding="0" width="100%"> 
    <tr> 
    <td style="padding: 2px;" class="bgmed"> 
     <strong>Customer</strong> 
    </td> 
    </tr> 

    sSQL = "SELECT " 
    sSQL = sSQL & " tbl.[Customer]" 
    sSQL = sSQL & " FROM tblCart"sSQL = sSQL & " WHERE" 
    sSQL = sSQL & " tbl.[Name] = 'Test' 

     </table> 

这是我使用的代码示例。在调用查询之后,我将表结果绑定到表。

+0

你将不得不显示我们你在循环中做什么。这将是整个过程中造成问题的其他处理。 – Paul 2014-09-23 15:18:26

+0

@Paul我的代码非常冗长。因此发布了示例代码。请看看这个。 – Ajay 2014-09-23 15:45:44

+1

不要在循环的每次迭代中使用'Response.Flush'来使用'Mod()'将其分解,所以它只刷新每一条如此多的记录。我确信我几天前在类似的帖子上写过这篇文章,是你吗?现在无法在任何地方找到该帖子,您是否删除它并重新发布? – Lankymart 2014-09-23 18:11:41

您不能同时使用这两种http://msdn.microsoft.com/en-us/library/ms525560(v=vs.90).aspx。 response.flffer必须为true才能使用response.flush。我甚至不知道为什么这样做会考虑MSDN如何声明它会导致运行时错误。

另外,您不应该在循环中使用response.flush。这意味着每次循环结束时都会向浏览器发送信息。这会导致太多推送到浏览器。

编辑: Lankymart在评论中提到使用循环的mod变体更频繁地刷新记录。为了OP,将它添加到我的答案中。这是你会做什么:

<% 
    sSQL = "SELECT " 
    sSQL = sSQL & " tbl.[Customer]" 
    sSQL = sSQL & " FROM tblCart"sSQL = sSQL & " WHERE" 
    sSQL = sSQL & " tbl.[Name] = 'Test' 
    counter = 0 
    rs.Open sSql, ConnectionString 
%> 
table border="0" cellspacing="0" cellpadding="0" width="100%"> 
    <tr> 
    <td style="padding: 2px;" class="bgmed"> 
     <strong>Customer</strong> 
    </td> 
    </tr> 
    <% 
    Do While Not rs.EoF 
    counter = counter + 1 
    %> 
    <tr> 
     <td> 
     <%= rs.Fields("Customer").value %> 
     </td> 
    </tr> 
    <% 
    if counter mod 10 = 0 then 
     Response.Flush 
    End If 
    rs.MoveNext 
    Loop 
    %> 
</table> 
+0

嗨,你是对的。现在我正在使用response.buffer = true。但正如你所说的,到底什么时候我应该使用response.flush。现在我的网页加载非常缓慢。 – Ajay 2014-09-23 15:46:53

+0

通常在重要菜单和网站导航被写入后使用。这个想法是让用户看到一个页面存在。在你的情况下,我可能会在你的循环之前执行它。 – KHeaney 2014-09-23 16:03:05

+0

如果您之后遇到问题,请考虑以某种方式分页您的表格。您发布到网页的结果有多少? – KHeaney 2014-09-23 16:04:58

在Dreamweaver我喜欢做这样使得不会引发不稳定...

</tr> 
<%dim bgcolor, counter 
bgcolor = "#E6E8FF" 
counter = 1 %> 
<% 
While ((Repeat1__numRows <> 0) AND (NOT rsSearch.EOF)) 
%> 
<% if counter mod 10 = 0 then 
     Response.Flush 
     End If %> 
     <tr bgcolor="<%=bgcolor%>" onMouseOver="changeto(event, '#ECE9D8')" onMouseOut="changeback(event, '<%=bgcolor%>')"> 
    <td align="left" valign="middle" nowrap="nowrap"><%=(rsSearch.Fields.Item("NAME").Value)%></td> 
    <td align="center" valign="middle" nowrap="nowrap"><%=(rsSearch.Fields.Item("ID").Value)%></td> 
    <td align="center" valign="middle" nowrap="nowrap"><%=(rsSearch.Fields.Item("WORK_AREA").Value)%></td> 
    <td align="center" valign="middle" nowrap="nowrap"><%=(rsSearch.Fields.Item("VIP_LOGIN").Value)%></td> 
    <td align="center" valign="middle" nowrap="nowrap"><%=(rsSearch.Fields.Item("ACTIVE").Value)%></td> 
    <td align="center" valign="middle" nowrap="nowrap"><%= DoDateTime((rsSearch.Fields.Item("LAST_LOGIN_DATE").Value), 1, 1033) %></td> 
    <td align="center" valign="middle" nowrap="nowrap"><%=(rsSearch.Fields.Item("EMAIL_ADDRESS").Value)%></td> 
    </tr> 
    <%counter = counter + 1%> 
    <% 
    Repeat1__index=Repeat1__index+1 
    Repeat1__numRows=Repeat1__numRows-1 
    rsSearch.MoveNext() 
Wend 
%> 
</table> 
<br />