Painful Windows Mobile experience

March 18th, 2008

One piece of the app we’re working on needs to be accessed from hand helds. No problem, right? It’s just a different view rendered to the mobile devices. JS, ajax should work as it is. Right? RIGHT?

Wrong. While I’ve read that IE has some Ajax support, I couldn’t make it work. This discussion set my expectation low. So, I downloaded Opera Mobile and wow, what a difference. Even the form validation using the Validation plug in worked. Still no Ajax. Just a few tweaks, right?

Wrong again. The jquery code that creates the XMLHttpRequest fails miserably on Opera. What is worst is that you have no clue of what is failing. No tooling, nothing even remotely similar to Firebug. So add try catches everywhere and prepare your patience.

To cut a long story short, I changed the code on jQuery source code – argh! – but got the XMLHttpRequest working. Just the first request went through, though. That one was easy: caching.

If you’re using MonoRail, all you have to do is:

public void YourAction()

and you’re done.

Requests are going through. No parameters, though. The request.send(“value=something”) doesn’t seem to work. Ok, to fix it make the parameters go through the URL. Ugly!!! But works.

Next problem, and the most involved one. My action returns JSON data:


And that’s what I got on the device:


Beautiful, isn’t it? My first guess: encoding problem.

I reviewed MonoRail and Newtonsoft.Json’s code almost a hundred times. No encoding relevant code. The response was set to utf-8. Decided to inspect the response’s content type. By default MonoRail’s JSONReturnBinder returns application/json, text/javascript which is right. Commented that line. Result:


Opera mobile seems to not associate that content type with anything, so it falls back to binary (!!!). Had to add the following hack to MonoRail’s JSONReturnBinder:

if (userAgent != null && userAgent.IndexOf("Windows CE") == -1)
    response.ContentType = "application/json, text/javascript";

Sometimes I love being a web developer… :-(

6 Responses to “Painful Windows Mobile experience”

Reshef Mann Says:

I see u tested on the emulator…
In case u didn’t run it on a real device u can expect a few more surprises as well.

hammett Says:

You’re kidding right? Haha, funny. Now, seriously, are you serious?

Gildas Says:

Hi Hammet,

My company is specialized on window mobile developments but not web on WM…

What I can tell you is that you should expect a lot more bad surprises like that. And yes, don’t use the emulators at all if you can, as the behaviour will not be the same at all on a real devices : sometime better, sometime worse.

To be honest, I was crying and wanting to hit real hard the Windows Mobile Project Manager for at least 3 years of headaches and nightmares ;-)

Good luck, and may the Windows Mobile Force be with you :D


Ben Scheirman Says:

I feel your pains… I did a college class project writing a game for pocket pc, but I didn’t have a pocket pc. I spent 2 weeks with the emulator, and I had vastly different result s deploying to the TA’s device.

Luckily it didn’t count against me, but my respect for mobile developers was raised quite a bit.

Do you plan to support the iPhone? My guess is that mobile safari will be much easier to support.

Colin Jack Says:

First off sorry that this is unrelated.

I’ve noticed that when I click to subscribe to your RSS I just get taken to the main site ( when in fact the RSS address is ( Just thought it might confuse some people.

Alessandro Riolo Says:

One of my best friends works for Buongiorno, probably the world biggest group in the mobile entertainment sector (they have revenues in the order of half a billion USD per year, and growing). It is his dream job, he ever wished to work in that sector, but when he tell me about his work, the tools they use and the limitations they have to overcome, I do really feel for him and all the mobile developers around the world.

Leave a Reply