dalcam
dalcam

Reputation: 1077

ASP.NET Resx Resource randomly giving null reference exception

I was viewing the error log for a site I develop for, and a certain line in a page is giving a null reference exception every now and then, very randomly. For example of the randomness, it maybe will return null once or twice in every 100 hits.
Here is the line:

@Resources.Global.ThankYou

And here is the structure of the resources folder (The Resources folder is at the root of the web project folder):

enter image description here

The users I have spoken to with the error all seem to be on english operating systems, and all the errors in the log I checked have this similarity in their passed HTTP request attributes:

HTTP_ACCEPT_LANGUAGE:en-au

And most but not all users that experience the issue seem to be on an iphone or ipad (some android too). To try and replicate the Issue I have pushed english-australian to the top of my language list and tested the exact same page, but it works fine - as it does for the other 98% of users, and picks up the default Global.resx ThankYou value which is in english.

Has anyone got any ideas to how some users could get the random null reference exception? I will be VERY grateful for any feedback!

Upvotes: 0

Views: 537

Answers (1)

dalcam
dalcam

Reputation: 1077

If this helps anyone, it ended up being a misleading exception from ASP.NET. The error was actually occurring in the following lines where a property of the model was null in some instances. ASP.NET Incorrectly was stating it was on the Resource. Here is an example I was able to replicate: enter image description here

The error was actually on the circled property 2 lines later, not on the line suggested by asp.net. I hope this helps!

Upvotes: 2

Related Questions