views:

223

answers:

3

I have a page with an iFrame whose source is an ashx page. The handler takes in 3 arguments through the query string and generates a text/html response containing a table. When the table gets >1700 rows it crashes the IE8 browser. The browser freezes and returns a null reference error.

If I take the html that is being rendered and place it inside a DIV on the page it renders fine in IE8. Any suggestions?

A: 

[update] From your comments, I do not believe the problem is the large table. Therefore, this answer does not apply, but I will leave it because it seems this question arises numerous times on SO.

Try "compatibility view", same problem?

Try reducing the page's size. For instance,

  1. strip unnecessary white space, (do first because it is easiest)
  2. temporarilly use css rule names of two characters for rules you use many times,
  3. temporarilly use control names and control ids of two or three characters for controls you use in repeater-like controls, such as data-lists, grids, and so on.

Notes

Public Class SearchPage
    Inherits System.Web.UI.Page

    'NOTE
    'short names for variables, controls, and so on, are specifically to reduce file size.

    'used 69,106 records for 
    '       testing/development (this will increase by 10,000 per month)
    'limited to 10,000 records for production (customer rarely will have more than 10,000 and only a few will always have 10,000+)

    Private Const DefaultResultLimit As Integer = 10000
    Private Const CheckPoint As Integer = 100


    Private Sub PopulateSearchResults(ByVal oResults As DataTable)
        Dim iCount As Integer

        For Each oRow As DataRow In oResults.Rows

            AddTableRow(tblBOM, New BomInfo(oRow))

            iCount += 1
            If (iCount Mod CheckPoint) = 0 Then
                If Not Me.Response.IsClientConnected Then
                    Exit For
                End If
            End If
            If iCount > Me.ResultLimit Then
                'limit results
                Exit For
            End If
        Next

    End Sub


    Private Sub AddTableRow(ByVal table As Table, ByVal bom As BomInfo)

        'NOTE
        'short names for variables, controls, and so on, are specifically to reduce file size.

        Dim oRow As New TableRow

        oRow.CssClass = "btr"

        oRow.Cells.Add(CreateCell(New HighlightControl(bom.ManufacturerName, _searchTerm, "sv"), "btc"))
        oRow.Cells.Add(CreateCell(New HighlightControl(bom.Mpn, _searchTerm, "sv"), "btc"))
        oRow.Cells.Add(CreateCell(New HighlightControl(bom.PartDescription, _searchTerm, "sv"), "btc"))
        oRow.Cells.Add(CreateCell(New HighlightControl(bom.Markings, _searchTerm, "sv"), "btc"))

        oRow.Cells.Add(CreateCell(bom.IcLength, "btc cntr"))
        oRow.Cells.Add(CreateCell(bom.IcWidth, "btc cntr"))
        oRow.Cells.Add(CreateCell(bom.PackageType, "btc cntr"))
        oRow.Cells.Add(CreateCell(bom.PinCount, "btc cntr"))
        oRow.Cells.Add(CreateCell(FormatCurrency(bom.ComponentPrice), "btch cr"))
        oRow.Cells.Add(CreateCell(FormatCurrency(bom.ComponentTotal), "btc cr"))
        oRow.Cells.Add(CreateCell(bom.Quantity, "btc cntr"))
        oRow.Cells.Add(CreateCell(bom.ReleaseDate, "btc cr"))
        oRow.Cells.Add(CreateCell(bom.ModelInfo, "btc"))
        oRow.Cells.Add(CreateCell(bom.ComponentFunction, "btc"))

        table.Rows.Add(oRow)

End Sub

    '...
    ElseIf oResults.Rows.Count > Me.ResultLimit Then
        'only display the records up to the limit
        'then notify user
        __recordLimitWarning.Text = " " + String.Format(Me.ResultLimitText, Me.ResultLimit.ToString("N0"))
        __recordLimitWarning.Visible = True

    End If
    '....
AMissico
Compatability mode causes the same problem. Only problem about slightly reducing the size is that we need to handle row counts of upwards of 8k. I know it seems like an unusable amount of data but we have business use cases where it makes sense.
Brian
I also had this requirement. Using the techniques above, I was able to use a DataGrid with 10,000 rows and page load of 5MB. (I do not remember the numbers, but this gives you an idea of the size I was dealing with.) I had to limit to 10,000 rows out of a possible 110,000+ rows. Original page load was 26MB. You will save significant space removing white-space, jscript compressor, css compressor, and so on. First strip white-space, see if you can get >1700. If you can, then you know it is page load. If not then maybe problem is in data.
AMissico
I just removed the iframe and pull just the html for the table down from a webservice and put this into the innerhtml of a div. This still caused IE8 to bomb.
Brian
Have you gotten pass >1700 rows? What is the page load in KB? You using inline styles or css classes?
AMissico
Does IE8 freeze? Have you run SysInternal's Task Manager and checked the process? Is IE8 just unresponsive?
AMissico
Have you used Fiddler to inspect the server response before it gets to the browser on client?
AMissico
-The page uses a mix of inline styles and css classes currently. -IE8 actually just closes and restarts.-Fiddler does show the response making it back and then actually crashes itself.
Brian
"IE8 actually just closes and restarts." I believe you can turn this off.
AMissico
You cleared IE Cache and cleared "temp" files?
AMissico
Does Fiddler show the response code? Can you see what it is before the crash?
AMissico
You cannot get pass 1700+. What happens if you start at 1600? Can you get past the 1600+100 = >1700+ mark?
AMissico
A: 

If I take the html that is being rendered and place it inside a DIV on the page it renders fine in IE8. Any suggestions?

Does the ashx handler render a complete html page or only the table fragment?

Make sure the page is valid html with html, body tags.

Also tables freeze the layout process in most browsers. Have you tried using div tags just to see if it crashs IE 8

ggonsalv
We've taken the html that renders and gone through it and ensured the table's structure is proper (i.e. proper tags and end tags etc.) and that all html is properly formed. Ran it through an HTML validator and it was fine. I'll give the div tags a try.
Brian
@Brian: What is size of rendered HTML?
AMissico
3mb for ~3k rows.
Brian
That seems a little much. Okay for development. Can you take this static HTML, save it locally, and open with the browser? Can you take this static HTML, save it on the Web Server and open it with the browser?
AMissico
Yes we can take the page and open it both locally and in on a dev server. We can even take the table's HTML from the page that is rendered in the iframe and place it in a div on the same page and have it render fine.
Brian
Then it is obvious from Fiddler's behavior and the results from using static HTML that the problem is the handler. It is not the size of the table or the page load. At this point, I suggest enabling page tracing for the application and figure out why Fiddler is crashing.
AMissico
A: 

The crash is being caused by an IE8 feature called SmartScreen. It prevents users from navigating to known malware and phishing sites. It also as a unintended feature prevents websites from pulling down large amounts of data after rendering. Once this feature is turned off the crashes go away completely.

Brian
Wow, how the heck did you figure that out?
AMissico
Worked with Microsoft directly.
Brian