WEIRDEST ERROR EVER: ASP.NET and Firefox?

Go To StackoverFlow.com

0

I've always thought that server-side code is unaffected by the browser requesting it, but I've just come across an exception:

I have a button that when clicked, changes the button's CSS class (and those relative to it) and rebinds a GridView with new data. The function is this:

Private Sub lbViewUnUsed_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbViewUnUsed.Click
    lbViewUsed.CssClass = "button small"
    lbViewUnUsed.CssClass = "button small selected"
    BindUsage(UsageBinding.UnUsed)
End Sub

In IE, this works perfectly. However, in Firefox, the BindUsage() function stops firing midway and nothing gets accomplished at all! In my frustration, I inserted Debug.Assert() statements after every line of code in the BindUsage() to see what was going on, and sure enough, the function would not go all the way through in Firefox ONLY.

The BindUsage() function is this (with the Debug assertions still in):

Private Sub BindUsage(ByVal bindWhat As UsageBinding)
    Debug.Assert(False, 1)

    If bindWhat = UsageBinding.Used Then
        gvUsage.DataSource = sUser.GetWordsMarkedWithUsage(True)
        gvUsage.Columns(0).Visible = False 'hide button column'
    Else
        Debug.Assert(False, 2)

        gvUsage.DataSource = sUser.GetWordsMarkedWithUsage(False)
        Debug.Assert(False, 3)

        Dim userInfo As UserAccount.LoginInfo = UserAccount.GetUserLoginInfo
        Debug.Assert(False, 4)

        Dim showUsedButton As Boolean
        Debug.Assert(False, 5)

        showUsedButton = (userInfo.UserName.ToLowerInvariant = sUser.UserName.ToLowerInvariant)
                       Debug.Assert(False, 6)

        gvUsage.Columns(0).Visible = showUsedButton 'show button column'
        Debug.Assert(False, 7)

    End If
    Debug.Assert(False, 8)

    gvUsage.DataBind()
    Debug.Assert(False, 9)

End Sub

The above function does not make it past 5 in Firefox. I'm guessing there's some sort of problem with the assignment of the showUsedButton variable, but I can't figure out what it would be. Why would this fail only in Firefox, but not in any other browser especially since this is occurring on the server???

2009-06-16 15:13
by Jason
What kind of error message are you getting - JasonS 2009-06-16 15:17
that's the thing, there's no error message... just nothing happens! debug assertions 6+ do not appear - Jason 2009-06-16 15:18
also, the CSS assignments from the calling function (the button click) do not actually happen even though they are called - Jason 2009-06-16 15:19


4

It's happening on the server, but you are retrieving data that was generated by the client:

UserAccount.GetUserLoginInfo

I would review your stored data and see what's different in it based on client application and see how it's handled.

2009-06-16 15:18
by sangretu
this fixed it... the case i was checking the user was not logged in so this was returning nothing and i guess making it fail. i needed to check to see if the user was authenticated, which i wasn't doing. thank you for putting me on the right track with this answer - Jason 2009-06-16 15:23
Did you fix the fact that you didn't get the details of the error? That sounds like a more serious issue to me, in that next time something bad happens, you'll be stuck with putting Asserts in again - Jon Skeet 2009-06-16 15:24
@jon - there were no details... i wasn't getting an error message, i was just not receiving the expected behavior. it just plain did nothing.... how would i get those details - Jason 2009-06-16 15:29
jon means that instead of just 'nothing' happening, you should instead see an exception thrown. Either as the common red-on-yellow error pages, or during debugging, but not nothing. It's very dangerous when errors are not reported / thrown but just swallowed instead. Are you doing some error handling in the Application_Error method in the global.asax - Razzie 2009-06-16 15:35


3

Well, it's a bit of a guess, but...

What exactly does UserAccount.GetUserLoginInfo do? If I had to guess, it tries to do something browser-specific. For example, it could try and read a cookie from the client? If it does, then my next guess is that userInfo or either userInfo.UserName is null, thus throwing a NullReferenceException.

It could be that IE accepts cookies, and firefox does not. Hence no error in IE, but only in Firefox. Again, this is guesswork, I'm not strong in VB.NET and have no idea what that UserAccount class is. Maybe if you'd give use the errormessage, it could mean some more.

2009-06-16 15:21
by Razzie
your instincts were correct. thank you for this - Jason 2009-06-16 15:23


1

Would you definitely spot if any exceptions were being thrown? If not, fix that before you do anything else.

As for why it might be browser-specific:

  • If it depends on what data is sent by the browser and how, then clearly the browser can change the behaviour
  • I believe ASP.NET renders in a browser-specific way; if your code is touching the rendering logic, it may be behaving differently depending on user agent.
2009-06-16 15:19
by Jon Skeet
Ads