How do you recognize Mobile Browser??


Hello Developers,

You all might have noticed when you browse any popular sites from any mobile device, your browser gives you a mobile compatible version of the same sites not the site you see on the desktop or laptop..Right!!!!

HOW DO THEY DO THAT…

Answer is very simple…They recognize the “User Agent” and do the tweaking.

User Agent holds the description about the browser, operting system, browser version, OS version etc. We can easily get this from the request header.

For example:

Mozilla/5.0 (Linux; U; Android 2.2.1; de-de; X2 Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1

This example shows the request has come from an Android device. Similarly there are different USER AGENTS for different devices. You can easily get this by using Javascript or Code Behind.

Javascript:  Using Navigator object. As

navigator.userAgent

ASP.NET CODE BEHIND: Using Request object

Request.ServerVariables[“http_user_agent”];

Now you can write a static helper method to recognize the requested device as below

public static bool IsMobileDevice(string userAgent)   {

userAgent = userAgent.ToLower();

return userAgent.Contains(“iphone”) |

userAgent.Contains(“android”) |

userAgent.Contains(“blackberry”) |

userAgent.Contains(“palm”);

}

Similarly you can have a Dictionary or List of devices and get the peroper device through these objects.

Thanks for reading this article.

With Personal Regards

Swagat

Emulators or Simulators Download


Hello Developers,

For Mobile Web development this is very important to know about the simulators and emulators. These are basically act as virtual mobile devices with the help of which testing can be done. But this could not give you the 100% testing result as on real mobile device. Still these are very useful to test with.

Here I am sharing different Mobile OS simulator/emulator download details.

1) iPhone & iPad Simulator – (Download)

2) iOS Simulator – (Download)

3) Android Emulator – (Download)

4) HP webOS Emulator for Palm Pre, Palm Pixi, Palm Pixi Plus – (Download)

5)  BlackBerry Simulators for 35 different models including series Bold, Curve, Pearl, Storm, Storm2, Style, Torch & Tour – (Download)

6)  Windows Phone 7 Simulator – (Download)

7)  Opera Mobile Emulator – (Download)

8)  Opera Mini Simulator – (Download)

9) PhoneGap Simulator for Apple iPhone, Generic Android, and others – (Download)

10)  Bada Simulator for Maemo (such as Nokia N900), Symbian Touch (such as Nokia N8) and Symbian non-touch (such as Nokie E71) – (Download)

11)  Garnet Emulator for Old Palm OS devices – (Download)

There are lots of other simulators and emulators are available like  Motorola-Xoom Add-on, Nokia Symbian, Samsung Galaxy Tab Add-On etc. But here I have listed the imortant ones to test with.

With Personal Regards

Swagat

 

 

Mobile Web Development Basics


Hello Developers,

This article is to share few basic notes regarding Mobile Web Application development. I am sharing few of the external post those I found very useful for a mobile web developer.

1) http://www.utexas.edu/web/guidelines/mobile.html

A growing number of users have portable devices like cell phones or portable digital assistants (PDAs) that they use to access information on the Web. The University has developed a Web site for mobile users at www.utexas.mobi. The guidelines below are intended to assist Web developers in preparing mobile-friendly content and applications. The W3C Mobile Web Best Practices Draft also has valuable information on developing for mobile devices.

Developers might notice that mobile-friendly sites and accessible sites have many common features including useful ALT text, single column design, no frames, no pop-ups, no Javascript, and no dynamic menus………………….

2) http://www.w3.org/standards/webdesign/mobilweb

The widespread deployment of Web-enabled mobile devices (such as phones) make them a target of choice for content creators. Understanding their strengths and their limitations, and using technologies that fit these conditions are key to create success mobile-friendly Web content.

See also the Mobile Web Initiative pages…………….

You can read through the above posts and I’ll be posting very good articles in near futures.

With Personal Regards

Swagat

How to recognize javaScript is enabled or not in browser?


Hello Developers,

As we all know Javascript is the most popular scripting language for all Web developers. But always there is a question from other end(customers). Question is something like this

If browser does not support JavaScript then what will happen to the JS logic?

Simple answer to this……..the JS logic will never work..:P

But we can think of some alternative like, why not ask the end user to enable the Javascript for your web application. Sounds crazy right!!!

But we have to go in this way. how do you do that?

This solution is simple…just include a HTML tag with few message then you are done. You can see below for example

<noscript> javascript is not enabled on your browser!!!!!!!! </noscript>

This <noscript> tag will do the work for you. As soon as user browses your site with Javascript disabled, this tag will execute and show the particular message. Otherwise this tag will never execute.

You can also try some samples and test in multiple browsers. this should work for you.

Thanks for reading this article.

With Personal Regards

Swagat

Windows Phone 7 Development Basic Notes


Introduction:

Windows Phone 7 is a great release from Microsoft, that gives developer to build very rich apps and has ability to compete with other mobile app platforms.

You can read through the release details on Scott’s blog

http://weblogs.asp.net/scottgu/archive/2010/09/16/windows-phone-7-developer-tools-released.aspx

Here I’ll share few basic design notes, which are very much required to know for a WP7 developer.

Development Environment Setup

For setting up your development environment you will be needed the below pre-requisites

Pre-requisites:

  • OS – Windows Vista or Windows 7 and you need to have a DirectX 10 capable graphics card.
  • Windows Phone Developer Tools package- You can download
  1. Visual Studio 2010 Express for Windows Phone
  2. Windows Phone Emulator
  3. Silverlight for Windows Phone
  4. XNA 4.0 Game Studio

Types of Application

There are two main categories under which the different applications can be developed

1)     Silverlight for Windows Phone

The below template are available in this category

2)     XNA Game studio 4.0

This framework helps to develop interesting Games which can be design wonderfully using object oriented programming.

Gaming studio consist of below applications

Design Tips

How to set the design view length and width?

WP7 app design view will be appearing on an emulator view, as it gives you the actual device effect as below.

So for developing lengthier screen which is more than the length of the design view, the design parameters should be set.  The d:DesignHeight=”768″ parameter needs to be set accordingly in the <phone:PhoneApplicationPage/> tab.

How to design with stack Grid panel?

Grid panel is used to set as the base panel or content panel, so that page content can be placed into it. Below is the sample script for this

<!–BasePanel is the root grid where all page content is placed–>

<Grid x:Name=”BasePanel” Background=”Transparent”>

<Grid.RowDefinitions>

<RowDefinition Height=”Auto”/>

<RowDefinition Height=”*”/>

</Grid.RowDefinitions>

<!—YOUR CONTENT–>

</Grid>

Below are the properties to remember while designing the content inside Grid

1.  Height

2.  Width

3.  Grid.Column

4.  Grid.Row

5.  Grid.ColumnSpan

6.  Grid.RowSpan

How to design with stack panel?

Stackpanel is used to place the controls inside and design with proper orientation(vertical and horizontal).

For example: if you want to place three images horizontally as below


Or place three images vertically as below


Sample Code:

<StackPanel Width=”480″ x:Name=”ImageStackPanel” HorizontalAlignment=”Center” VerticalAlignment=”Stretch” Margin=”0″ Orientation=”Horizontal”>

<Image Height=”159″ Name=”Image1″ Stretch=”Fill” Width=”160″ Source=”images/1.jpg” />

<Image Height=”159″ Name=”Image2″ Source=”images/2.jpg” Stretch=”Fill” Width=”161″ />

<Image Height=”159″ Name=”Image3″ Source=”images/3.jpg” Stretch=”Fill” Width=”157″ />

</StackPanel>

How to activate scroll bar?

Scroll bar option can be introduced by just including the ScrollViewer tag.

Sample Code:

<Grid x:Name=”ContentPanel” Grid.Row=”1″  Margin=”0,0,0,-132″>

<ScrollViewer>

<StackPanel Width=”480″ x:Name=”ImageStackPanel” HorizontalAlignment=”Center” VerticalAlignment=”Stretch” Margin=”0″ Orientation=”Vertical”>

<Image Height=”159″ Name=”Image1″ Stretch=”Fill” Width=”160″ Source=”images/1.jpg” />

<Image Height=”159″ Name=”Image2″ Source=”images/2.jpg” Stretch=”Fill” Width=”161″ />

<Image Height=”159″ Name=”Image3″ Source=”images/3.jpg” Stretch=”Fill” Width=”157″ />

</StackPanel>

</ScrollViewer>

</Grid>

How to navigate to other  page

Navigate method of NavigationService class is required to navigate to the next screen/page/window.

e.g.

NavigationService.Navigate(new Uri(“/mypage2.xaml”, UriKind.Relative));

This method also helps to send data from one screen to another using QueryString.

e.g.

NavigationService.Navigate(new Uri(“/mypage2.xaml?parm=” + TextBox.Text, UriKind.Relative));

How to retrieve the parameter?

e.g.

String myparam= String.Empty;

if (NavigationContext.QueryString.ContainsKey(“parm”) == true)

{

myparam = NavigationContext.QueryString[“parm”].Trim();

}

For more details, please visit below links

1) Getting Started with Windows Phone Development

http://www.windowsphonegeek.com/Resources/GettingStarted#getstarted

2) WP7 Dev Guide 

http://www.windowsphonegeek.com/Resources

3) Application Platform Overview for Windows Phone

http://msdn.microsoft.com/en-us/library/ff402531(v=VS.92).aspx

Thanks for reading this article

Swagat


Web.Config conflict issue


Hello developers,

In this article i am going to describe an interesting topic regarding ASP.NET web application hosting issue due to Web.Config configuration.

I want to give an live example which would make this issue more easier to understand…

When I was working in a Web Application(WAP A), it has 3 sub Web Applications(WAP B, WAP C, WAP D). All applications were havng their own solution and project file. While development there were no config issues as I directly compile the code and run.

But the moment I pushed one of the Web Application(WAP C) into the server after creating its virtual directory then I met an issue called Web.Config conflict issue. The WAP C application was throwing errors on Config file. You must be wondering with this. you might think also that I could have done some wrong Virtual directory settings. Ok you would get your all answers below.

OUR SITE AND VIRTUAL DIRECTORY STRUCTURE ON SERVER

The setups were like below

-> Root( Web Site – WAP-A.com)

-> Virtual Directory( WAP-A.com/WAP-B/)

-> Virtual Directory( WAP-A.com/WAP-C/

-> Virtual Directory( WAP-A.com/WAP-D/)

And the Directory structure were like below

WAP A was inside D:/WAP A/ directory.

And all others were inside D:/WAP A/ like D:/WAP A/WAP B/.

When I completed the virtual directory setup for WAP B then I got the below error while running  http://WAP-A.com/WAP-B/

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: The entry ‘asp:System.Web.UI:System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ has already been added.

Source Error:

Line 30: <pages validateRequest=”false”>

Line 31: <controls>

Line 32: <add tagPrefix=”asp” namespace=”System.Web.UI” assembly=”System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>

Line 33: <add tagPrefix=”ajaxToolkit” namespace=”System.Web.UI” assembly=”System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>

Line 34: <add tagPrefix=”ajaxToolkit” namespace=”AjaxControlToolkit” assembly=”AjaxControlToolkit”/>

And when I tried commenting the above tags in WAP B config file then it threw an issue in the below line

Line 80: <add name=”ScriptModule” type=”System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>

Again I commented the above line in WAP B config file, then it threw another error as below

Line 71: <add verb=”*” path=”LanappCaptchaa.aspx” type=”Lanapp.BotDetectt.CaptchaaHandler, Lanapp.BotDetectt”/>

Above was the assembly info for a 3rd party DLL. It could be any thing.

Then I included the particular DLL into the WAP B bin folder and the site worked fine.

Just think why all these issue happened while hosting, and I never faced this on development phase.

Reason-

When we host any virtual directory under the site which has the Config file with same tags, then the Virtual Directory site considers the tags as duplicate tags in its Web.Config file. The Parent chile relationship would be generated in such cases. So the Child site would inherit the properties or tags in Web.Config file from the main or root site. This is the reason why the 3rd party DLL assembly info issue came up. Because the child site got the info from parent config file that it needs the assembly configuration in the solution. So after placing the proper DLL the issue got resolved.

Hope the above explanation helps you all in understanding this issue. Also make sure that you create the same environment on your development phase before publishing into production. it helps us to avoid such kind of unknown issues.

Thanks for reading this article.

With Personal Regards

Swagat


Failed to access IIS metabase Error


Hello Developers,

Failed to access IIS metabase” error might have faced by so many developers while deployment stage.

Cause of this issue:

This error occurs when you install IIS after installing .NET Framework. So IIS does not resolve the .NET framework  .

Solution:

If we install .NEt Framework after installing IIS then, IIS is automatically configures to handle requests to ASP.NET pages, and to redirect the execution to the ASP.NET runtime.

But in this situation we have to make use of aspnet_regiis.exe utility to register ASP.NET into IIS.

How to configure? :

You can copy and paste this command into windows command prompt

%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i

this will fix this issue. You should be installing this for all version you want to configure.

 

Thanks for reading this article

Swagat