Yesterday I was working with one of our customers to fix an issue with an ASP.NET application throwing an error. That application threw the error on the first request coming in through Azure Front Door. When we sent a request to the original (back end) URL, the application worked fine and never threw the exception. 🤔
Time to investigate…!
Finding the cause 🧐
First step of course was to find the cause of the exception. With all the logging in place like
Application Insights Azure Monitor that didn’t take too long. Because the application is rolled out internationally, they initially use the user’s preferred language set in the browser to determine the language to display to the user. The error was on the line where they read the
UserLanguages from the incoming request. As it turns out, that property was
null for the request coming from Azure Front Door.
Solving the issue
We couldn’t find a (quick) solution to make the first request actually have all the properties expected in the ASP.NET Application. So the temporary workaround was to default to the
en-us locale whenever the
UserLanguages property was
null. Granted, it’s kinda not OK this threw an exception instead of gracefully degrading. On the other hand: now we could see something was going wrong.
Testing 🚪 Front Door
To test this I created a web application and put it behind the Front Door service. In that test application I iterate over all the properties of the
HttpContext.HttpRequest and print them out. As far as I can see right now, there are two properties that have differences between a direct request and a request through Front Door. Both the
AcceptTypes and the
UserLanguages property are empty for Front Door requests, while they are absolutely filled in when directly accessing the test application.
I’m not quite sure what the reason is for the first Front Door request to be different from a direct request. Is it a bug? Is it intentional and if so, why? Or is it because Front Door is developed using a framework that doesn’t support these properties, having them be empty when being forwarded?
I’ll keep looking in to this. If I find an answer, this blog post will be updated. For now I hope this post helps at least one person with the same issue.
If you’re running into this or other issues or have any questions, don’t hesitate to contact me.