Month: February 2011

Developing ASP.NET Web Applications for Windows Phone 7

Let me start this blog post with Congratulating Microsoft, for Windows Phone 7. I bought Windows Phone (HTC HD7) one month back, and it was amazing device. Since I’m a ASP.NET Web application developer and eager to develop web applications for Windows Phone 7.  

Developing ASP.NET Web application and testing those is pretty simple. Thanks to Microsoft once again, for providing free Visual Studio Express 2010 for Windows Phone absolutely free, which includes Windows Phone 7 emulator.

You can download Visual Studio Express 2010 for Windows Phone from this link.

Let us start writing a simple web application, which targets the Windows Phone 7. As usual, start Visual Studio 2008/2010, and create a ASP.NET website project, and add simple text as shown below.

image

Deploy the Web application to the local IIS Server, then try to access  web application in Windows Phone emulator, which I got with Visual Studio Express 2010 for Windows Phone. Here we go,

                                                    image

Oops, the text is showing very small, not able to read what it is. By default it renders like shown in the above emulator. Don’t worry, we can resolve this issue pretty easy with some cool META tags.

Just add any one of the  following META tags, in the head section of you page.

image

I added both the META tags, but one is sufficient. Now run this web app in Windows Phone emulator, here we go

                                    image

Woooww, it’s working. You are done, creating a simple web application for Mobile Phones. You can add all the ASP.NET controls, and all controls renders awesome in Windows Phone 7.

ASP.NET may fail to detect the Windows Phone browser as Mobile browser. To overcome this issue, your can use Mobile Device Detection code provided at http://51degrees.codeplex.com

Here’s an awesome example to detect the Mobile browsers and redirecting to a Mobile site etc.,

http://www.asp.net/learn/whitepapers/add-mobile-pages-to-your-aspnet-web-forms-mvc-application

Happy Web App development for Windows Phones!!!