[英]Convert html page to a image using webbrowser in asp.net taking Too much time to generate image of heavy html page
[英]Postback Request of ASP.NET Controls are taking too much time
我创建了一个 asp.net 网站http://www.oureasymart.com在 localhost 中运行良好。 但是在将其托管给godaddy之后,当单击asp.net控件之类的按钮时,执行其操作需要花费大约1分钟的时间。 这个问题是针对每个asp.net控制的每一页。 我认为后面的代码或单击事件没有问题,因为我尝试了一个简单的 Response.Redirect() 方法来在单击该按钮时移至下一页,但仍然需要相同的时间。 我也尝试在 Jquery Ajax 的帮助下调用相同的方法,它工作正常。 我还启用了跟踪,在该跟踪中我检查了没有事件甚至需要 1 秒。 请查看跟踪信息的代码和屏幕截图,并提出可能的问题。 跟踪信息: https://drive.google.com/file/d/19Cl6wpe_Y20FCzxI9d0bUvj8BdaUdgjR/view?usp=drivesdk
在跟踪信息中,通过搜索产品然后单击产品搜索页面中的页面索引来截取屏幕截图。
<div class="row">
<asp:Repeater ID="repeater1" runat="server">
<ItemTemplate>
<div id="lblsp" class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="my-list hovereffect w3l-pricehkj">
<img src='data:images/png;base64,<%# Eval("Img1") != System.DBNull.Value ? Convert.ToBase64String((byte[])Eval("Img1")): string.Empty %>' alt="IMG-PRODUCT" style="max-height: 200px;min-height:200px" />
<h3><%#Eval("Prod_Name") %></h3>
<div class="single-infoagile" style="margin-top: 10px">
<ul>
<li>Cash on Delivery Eligible.
</li>
<li>Shipping Speed to Delivery.
</li>
</ul>
</div>
<h6><span>₹<%#Eval("Cost")%></span></h6>
<asp:HiddenField ID="hid_packageId" runat="server" Value='<%#Eval("Prod_Name") %>' />
<div class="overlay">
<h2><%#Eval("Prod_Name") %></h2>
<a class="info" href="ViewProduct.aspx?Name=<%#Server.UrlEncode(Eval("Prod_Name").ToString()) %>">View Details</a>
<input id="btn_addtocart" type="button" class="info" causesvalidation="false" value="Add to Cart" />
</div>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
<br />
</div>
</div>
</div>
<div class="pagechange">
<table>
<tr>
<asp:Label ID="lblpage" runat="server" Text="" Font-Size="Medium"></asp:Label></tr>
<tr>
<td>
<input id="btn_Prev" type="button" class="btn-link" causesvalidation="false" value="<" />
</td>
<td>
<asp:DataList ID="rptPaging" runat="server" OnItemCommand="rptPaging_ItemCommand" OnItemDataBound="rptPaging_ItemDataBound"
RepeatDirection="Horizontal">
<ItemTemplate>
<asp:LinkButton ID="lbPaging" runat="server" CommandArgument='<%# Eval("PageIndex") %>' CommandName="newPage"
Text='<%# Eval("PageText") %> ' Width="20px">
</asp:LinkButton>
</ItemTemplate>
</asp:DataList>
</td>
<td>
<input id="btn_Next" type="button" class="btn-link" causesvalidation="false" value=">" />
</td>
</tr>
</table>
</div>
**Code Behind:**
protected void rptPaging_ItemCommand(object source, DataListCommandEventArgs e)
{
if (!e.CommandName.Equals("newPage")) return;
CurrentPage = Convert.ToInt32(e.CommandArgument.ToString());
BindDataIntoRepeater();
}
private void BindDataIntoRepeater()
{
if(_pgsource.DataSource ==null)
{
var dt = GetDataFromDb();
_pgsource.DataSource = dt;
}
_pgsource.AllowPaging = true;
// Number of items to be displayed in the Repeater
_pgsource.PageSize = _pageSize;
_pgsource.CurrentPageIndex = CurrentPage;
// Keep the Total pages in View State
ViewState["TotalPages"] = _pgsource.PageCount;
// set Previous, Next buttons visible
//lblPrevious.Visible = !_pgsource.IsFirstPage;
//lbNext.Visible = !_pgsource.IsLastPage;
// Bind data into repeater
ProductSearch p = new ProductSearch();
p.repeater1.DataSource = _pgsource;
p.repeater1.DataBind();
// Example: "Page 1 of 10"
int total = 0;
if (ViewState["total"] != null)
{
total = (int)ViewState["total"];
}
lblpage.Text = "Page " + (CurrentPage + 1) + " of " + _pgsource.PageCount + "(" + total + " resultS)";
// Call the function to do paging
HandlePaging();
}
private void HandlePaging()
{
var dt = new DataTable();
dt.Columns.Add("PageIndex"); //Start from 0
dt.Columns.Add("PageText"); //Start from 1
_firstIndex = CurrentPage - 5;
if (CurrentPage > 5)
_lastIndex = CurrentPage + 5;
else
_lastIndex = 10;
// Check last page is greater than total page then reduced it
// to total no. of page is last index
if (_lastIndex > Convert.ToInt32(ViewState["TotalPages"]))
{
_lastIndex = Convert.ToInt32(ViewState["TotalPages"]);
_firstIndex = _lastIndex - 10;
}
if (_firstIndex < 0)
_firstIndex = 0;
// Now creating page number based on above first and last page index
for (var i = _firstIndex; i < _lastIndex; i++)
{
var dr = dt.NewRow();
dr[0] = i;
dr[1] = i + 1;
dt.Rows.Add(dr);
}
rptPaging.DataSource = dt;
rptPaging.DataBind();
}
我找到了这个原因。 实际上在按钮单击查看 State 有大量数据,因为我使用了中继器控制。 这导致延迟到达服务器的到达请求。 我为转发器禁用了 View State,这解决了问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.