2010-05-07 28 views
1

有人可以解釋一下firefox updatepanel異步回傳與IE中執行的回顯之間的速度差異嗎?微軟討厭Firefox嗎? ASP.Net的GridView性能在Firefox的錯誤?

平均火狐回傳時間爲500個對象:1.183第二

平均值,即回傳時間爲500個對象:0.295秒

使用Firebug我可以看到,大部分的這段時間在Firefox都花在服務器上側。總共1.04秒。

鑑於這個事實,我可以假設的唯一原因就是ASP.Net在兩個瀏覽器之間呈現其控件的方式。

有沒有人遇到過這個問題?

VB.Net代碼

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click 
     GridView1.DataBind() 
    End Sub 

    Public Function GetStockList() As StockList 
     Dim res As New StockList 

     For l = 0 To 500 
      Dim x As New Stock With {.Description = "test", .ID = Guid.NewGuid} 
      res.Add(x) 
     Next 

     Return res 
    End Function 


    Public Class Stock 
     Private m_ID As Guid 
     Private m_Description As String 

     Public Sub New() 
     End Sub 

     Public Property ID() As Guid 
      Get 
       Return Me.m_ID 
      End Get 
      Set(ByVal value As Guid) 
       Me.m_ID = value 
      End Set 
     End Property 

     Public Property Description() As String 
      Get 
       Return Me.m_Description 
      End Get 
      Set(ByVal value As String) 
       Me.m_Description = value 
      End Set 
     End Property 
    End Class 

    Public Class StockList 
     Inherits List(Of Stock) 

    End Class 

標記

<form id="form1" runat="server"> 
    <asp:ScriptManager ID="ScriptManager1" runat="server"> 
    </asp:ScriptManager> 

    <script type="text/javascript" language="Javascript"> 

function timestamp_class(this_current_time, this_start_time, this_end_time, this_time_difference) { 
     this.this_current_time = this_current_time; 
     this.this_start_time = this_start_time; 
     this.this_end_time = this_end_time; 
     this.this_time_difference = this_time_difference; 
     this.GetCurrentTime = GetCurrentTime; 
     this.StartTiming = StartTiming; 
     this.EndTiming = EndTiming; 
    } 

    //Get current time from date timestamp 
    function GetCurrentTime() { 
     var my_current_timestamp; 
     my_current_timestamp = new Date();  //stamp current date & time 
     return my_current_timestamp.getTime(); 
     } 

    //Stamp current time as start time and reset display textbox 
    function StartTiming() { 
     this.this_start_time = GetCurrentTime(); //stamp current time 
    } 

    //Stamp current time as stop time, compute elapsed time difference and display in textbox 
    function EndTiming() { 
     this.this_end_time = GetCurrentTime();  //stamp current time 
     this.this_time_difference = (this.this_end_time - this.this_start_time)/1000; //compute elapsed time 
     return this.this_time_difference; 
    } 

//--> 
</script> 
<script type="text/javascript" language="javascript"> 
    var time_object = new timestamp_class(0, 0, 0, 0); //create new time object and initialize it 

    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler); 
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler); 
    function BeginRequestHandler(sender, args) { 
     var elem = args.get_postBackElement(); 
     ActivateAlertDiv('visible', 'divAsyncRequestTimer', elem.value + ''); 
     time_object.StartTiming(); 
    } 
    function EndRequestHandler(sender, args) { 
     ActivateAlertDiv('visible', 'divAsyncRequestTimer', '(' + time_object.EndTiming() + ' Seconds)'); 
    } 
    function ActivateAlertDiv(visstring, elem, msg) { 
     var adiv = $get(elem); 
     adiv.style.visibility = visstring; 
     adiv.innerHTML = msg; 
    } 
</script> 

    <asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
    <Triggers> 
     <asp:AsyncPostBackTrigger ControlID="Button1" EventName="click" /> 
    </Triggers> 
     <ContentTemplate> 
      <asp:Button ID="Button1" runat="server" Text="Button" /> 
      <div id="divAsyncRequestTimer" style="font-size:small;"> 
      </div> 
      <asp:GridView ID="GridView1" runat="server" DataSourceID="ObjectDataSource1" AutoGenerateColumns="False"> 
       <Columns> 
        <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" /> 
        <asp:BoundField DataField="Description" HeaderText="Description" 
         SortExpression="Description" /> 
       </Columns> 
      </asp:GridView> 

      <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
       SelectMethod="GetStockList" TypeName="WebApplication1._Default"> 
      </asp:ObjectDataSource> 
     </ContentTemplate> 
    </asp:UpdatePanel> 

    </form> 
+0

BTW:我使用Firefox 3.6.3和IE:8.0.7600 – 2010-05-07 18:11:33

+1

你釘了它。查看反射器中的代碼,如果用戶正在運行Firefox,則會看到他們將響應線程休眠1秒(IsDetestableBrowser方法返回true)。 – 2010-05-07 18:24:42

回答

1

我猜測它的初始時間來編譯頁面。當我首先運行IE頁面時,它會在一秒鐘內渲染,然後在Firefox中運行該頁面大約需要0.2秒。

+0

這似乎不是一個編譯的東西。我的結果與你的不匹配。它們如上所述通過多次回傳保持一致。我現在會在另一臺機器上嘗試它。 – 2010-05-07 18:23:11

+0

在開發服務器上,我的結果現在與您的結果匹配......我的不好! Firefox在我的情況下也呈現得更快(微軟喜歡firefox?lol),但是我可以錄製我的開發環境的視頻,其行爲如同描述的那樣....讓人討厭......對不起所有! – 2010-05-07 18:33:28