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???
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.
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.
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: