A search aspx page return slow

北城余情 提交于 2019-12-24 20:48:54

问题


I have a asp.net website, there is a searchResult.aspx, it runs a sql script to retrieve data from MS SQL server database, and then put the data into a HTML format, the website has been deployed in IIS7.5 Server. I have implemented both static and dynamic compression, that means all my js, css and aspx page have been compressed before rendered to browser.

Unfortunately the searchResult.aspx return very slow, if search for a big word, like biography, it averagely takes more than 10 seconds to return. and I used firebug Net to trace it, the blocking, DNS Lookup, Connecting and Sending all take no more than 10ms, but the Waiting takes over 10 seconds. So I added some code to the beginning and end of function Page_Load(object sender, EventArgs e) and also the begining and end of HTML body element, like below:

   protected Stopwatch stopwatch = new Stopwatch();
   protected void Page_Load(object sender, EventArgs e)
    {
        stopwatch.Start();
        ....
        stopwatch.Stop();
        timeForSearch = stopwatch.Elapsed.Milliseconds;
     }


    <body>
      <%
       stopwatch.Reset();
        stopwatch.Start();
       %>
       ....


      <%stopwatch.Stop();%>
 <%=timeForSearch%>+<%=stopwatch.Elapsed.Milliseconds%>=<%=stopwatch.Elapsed.Milliseconds + timeForSearch%>

Ok, usually the timeForSearch and time for filling aspx page are totally 1 second, but why the page takes over 10 seconds to load, any help will be appreciated it.


thanks for replying, the aspx page has been gzip to 8.2KB. not a big file


回答1:


Try to set the Trace property of @Page directive to true.

<%@ Page ... Trace="true" %>

In the "Trace Information" section you will identify which page life-cycle event is demanding more time to execute and perhaps help you to debug.

Are you using Master Pages? Do you have any user controls on your page? User control events occur after their parent's events. I.e., UserControl.Init occurs after Page.Init (but before Page.Load), and UserControl.Load occurs after Page.Load.

If so, you may want to investigate the Page_Load in those controls.




回答2:


I thought maybe I fixed it, I disable the IIS log, then the search page can be loaded within 3 to 5 seconds, it seems improve a lot. But I am still thinking about that disabling IIS log is a good choice.



来源:https://stackoverflow.com/questions/9797825/a-search-aspx-page-return-slow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!