简体   繁体   English

ASP。 NET C#Web应用程序性能问题

[英]ASP. NET C# Web Application Performance Issues

I have an ASPX page with 40 ++ Drop Down List in a table generated from back-end C# code as shown: Drop Down Lists 从后端C#代码生成的表中,我有一个带有40 ++下拉列表的ASPX页面,如下所示: 下拉列表

These drop down list can be searchable with the help 3rd party jQuery below: 这些下拉列表可以使用下面的帮助第三方jQuery进行搜索:

<script src="../Scripts/jquery-1.8.3.min.js" type="text/javascript" ></script>
<script src="../Scripts/jquery.searchabledropdown-1.0.8.min.js" type="text/javascript"></script>

Everything working fine except when the page is loaded it is very slow which took about 20 to 30 seconds. 一切正常,除了加载页面时,它非常缓慢,耗时约20到30秒。

Any advice guys? 有什么建议吗? Is there any other way around or other better recommendation on the wild search? 在野外搜索还有其他方法或其他更好的建议吗?

Thanks... 谢谢...

This is the summary of the back end code: 这是后端代码的摘要:

//This chunk build the drop down list in the table
for (int y = 1; y <= DETAIL_ROW; y++)
{
     DropDownList InternalOrderDDL = new DropDownList();
     InternalOrderDDL.ID = "InternalOrderDDL" + y.ToString();
     InternalOrderDDL.Width = Unit.Percentage(100);
     InternalOrderDDL.Attributes.Add("onfocus",   "ChangeDropDownWidth(this);");
     InternalOrderDDL.Attributes.Add("onblur", "ResetDropDownWidth(this);");

     HtmlTableCell InternalOrderCell = new HtmlTableCell();
     InternalOrderCell.Controls.Add(InternalOrderDDL);

     NewRow.Cells.Add(InternalOrderCell);
     DetailTable.Rows.Add(NewRow);
}

//This chunk of code populate the Drop Down List 
DataTable InternalOrderDT = new DataTable();

using (SqlConnection Conn = new SqlConnection(CONNECTION_STRING))
{
    SqlCommand Cmd = new SqlCommand("spActiveInternalOrderRetrieveListByCompany", Conn);
    Cmd.CommandTimeout = 0; 
    Cmd.CommandType = CommandType.StoredProcedure;
    Cmd.Parameters.Add("CompanyID", SqlDbType.NVarChar).Value = companyID;
    Conn.Open();
    SqlDataReader Dr = Cmd.ExecuteReader();
    InternalOrderDT.Load(Dr);
    Conn.Close();
}

for (int y = 1; y <= DETAIL_ROW; y++)
{
    DropDownList InternalOrderDDL = DetailTable.FindControl("InternalOrderDDL" + y.ToString()) as DropDownList;
    InternalOrderDDL.DataTextField = "InternalOrderName";
    InternalOrderDDL.DataValueField = "InternalOrderID";
    InternalOrderDDL.DataSource = InternalOrderDT;
    InternalOrderDDL.DataBind();
    InternalOrderDDL.Items.Insert(0, new ListItem("--", ""));

}

My tip is to cache data. 我的技巧是缓存数据。 Check which of the 40 drop down list can be cached, from data you won't need to get data from the database, but using from the cache. 检查40个下拉列表中的哪个可以从不需要从数据库获取数据的数据中进行缓存,而是从缓存中使用。 It will save you some seconds and reduce the amount of time spent with the rendering. 这将节省您几秒钟的时间,并减少渲染所花费的时间。 Also check the possibility of using OutputCache. 还要检查使用OutputCache的可能性。

Another thing that may worth is check the database performance. 可能值得做的另一件事是检查数据库性能。 Check if there's some old data that could be archived. 检查是否有一些旧数据可以存档。 Also check if there's any missing index and if the queries are returning only the data you need, rather than all the fields from the table. 还要检查是否缺少索引,查询是否仅返回您需要的数据,而不是表中的所有字段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM