WP7 App on WP8 Breaking Changes – Part 1 – WebRequest’s Referer Changes

Well, after testing a WP7 app running on WP8 guess what happened…It worked differently on WP8.
The issue as described was : Almost all of the thumbnails stopped showing when the user was logged in.

That was an interesting one. It was obvious it was an MS bug (check out the other one I discovered as well here).

Btw let me say that the MS guys have done an amazing job with WP8! They worked really hard to make the deadlines and try to keep that huge promise that all WP7 apps would automagically run as-is on WP8. Huge effort from their part.

Time to relax back and do some bug-hunting 🙂

Thumbnails mean WebRequests. The ones that failed were shown by setting the UriSource on a BitmapImage. We need to go ask the BitmapImage what goes wrong with the requests when running inside a WP8 device. So lets setup fiddler so we can check the traffic. Note that my PC and the WP8 device were connected to the same Wifi network.

Below you can see how to setup the proxy on the phone’s wifi connection (tap on it for settings).

Great. Now I was able to compare the requests made from a WP7 and WP8 device.

Long story short, I was able to pinpoint the issue and it had to do with the fact that

On WP8 MS changed the way they handle/send Referer headers in WebRequests for both  BitmapImage and WebClient

Why my problem occurred : As it turns out the thumbnail requests, once logged in, are authenticated and in that case the server uses the Referer in order to authenticate the request. If the referer is different than the one you used to log in (through a WebClient) the request will fail. So when a WP7 app runs in WP7 device both the BitmapImage and the WebClient send the identical referer (Applications/Installl) but when a WP7 app is running on WP8 then BitmapImage sends a different Referer than what the WebClient sent to the server while authenticating resulting in all thumbnails to fail.

Lets setup a small test case to highlight and visualize the issue.

Here is the test we are going to run :

We are going to try it in 3 scenarios so we can see the results. The scenarios are :

  1. A WP7 app running on WP7
  2. A WP7 app running on WP8
  3. A WP8 app running on WP8

And now here are the results in order :

WP7 app running on WP7

Figure 1 : BitmapImage request (WP7 on WP7)

Figure 2 : WebClient request (WP7 on WP7)

WP7 app running on WP8

Figure 3 : BitmapImage request (WP7 on WP8) changed!


Figure 4 : WebClient request (WP7 on WP8) as normal

WP8 app running on WP8

Figure 5 : BitmapImage request (WP8 on WP8)

Figure 6 : WebClient request (WP8 on WP8).

The problem should be really obvious by now.

Concern #1 : I pretty much can’t do anything to workaround this issue. Changing the whole app to manually download all thumbnails is not an option.

Concern #2 : what should we do from now on WP8 for new Apps as far as Referer’s are concerned?

Do we need to use Data/Programs from now on?
Does that mean that for new apps on WP8 we will have to now manually inject the Referer ourselves on all webrequests? And so on…

I have create a forum thread on Microsoft’s WP forums on the issue here