Great Tools for Testing Your Website on Mobile Devices

Smartphones and other handheld devices contribute substantially to the overall viewership of any website. Latest estimates show that it is not long before the mobile Internet users are slated to have more stake in the website usage from their desktop and laptop counterparts.

In such a scenario it would be a cardinal sin to ignore the mobile users when it comes to development of a website. Thus one of the most important stages is making a website mobile friendly is to test it for different smartphone platforms and other handheld devices. Let us take a look the importance of mobile phone emulators when it comes to designing websites.

  1. A mobile phone emulator allows you to check the responsiveness and functionality of the mobile websites across different mobile platforms such as iPhone, Android, BlackBerry, iPad etc.
  2. Mobile emulators pinpoint the problems and issues concerning the website and allow you to take corrective measures to make the website visually appealing and functional on smartphones and other hand held devices.
  3. A mobile emulator eases the process of website testing and does away with the technique of testing the website on different devices. The developers can test the website on a virtual mobile interface with all the functionalities available on a device.
  4. Testing through mobile emulators works perfectly on touch based phones and the traditional QWERTY based smartphones.

There are a number of mobile phone emulators available in the market and here we’ll take a look at some of the most popular among them.

iPhone Tester

As the name suggests, this is one of the most popular mobile emulators which is used for checking the compatibility of a website on the iPhones. All that you need to do is enter the URL of your website into the search box and get a real-time preview of how it would appear on an iPhone.

Mobile Phone Emulator

This is surely one of the most popular mobile phone emulators that is being used by a large number of developers. The greatest advantage with this tool is that it tests the compatibility of the website across a large number of platforms including Samsung, iPhone, BlackBerry etc.

iPad Peek

iPad is surely the most acclaimed tablet available in the market and to ensure that your website is compatible with iPads you can try out iPad Peek. It will replicate the appearance and functionality of your website on an iPad.

Screenfly

This is one of the best preview tools as it allows you to see how the website would be rendered by a number of mobile devices apart from the traditional desktops and laptops. You can customize it the way you would like to test your website under various categories. This is a must have emulation tool due to its wide coverage of platforms.

MobiReady

This works similar to Gomez and allows you to enter the URL of your website and test the website along different parameters including Page Test, Markup Test and Site Test. What makes it even more powerful than Gomez is the fact that it checks many other parameters such as dotMobi compliance and W3C mobile compliance, offering detailed error reports. It also has a comprehensive code checker which comes in handy.

This article is copied from this article.

Will JSON win over XML?

JavaScript Object Notation (JSON), also called the Fat-Free alternative of XML, is a technique for passing structured data across processes in the form of a string. This technique results in the ability to pass JSON data across network protocols that prefer string traffic, such as HTTP.

Data can be serialized into a JSON string much the same as XML. The key difference is that JSON uses a serialization technique that results in much smaller strings than XML. JSON has also been a popular implementation for using RESTful applications. It allows easy communication of objects from a client to/from a web server. Using JSON you can cause a web application to perform work or manipulate data. You can also receive results back from a REST application in the form of JSON object notation. Like XML, JSON can also be a complex object. It can contain collections in the form of an array. It can have complex data types consisting of multiple public properties, etc…

Sample JSON:

{
    "glossary": {
        "title": "example glossary",
		"GlossDiv": {
            "title": "S",
			"GlossList": {
                "GlossEntry": {
                    "ID": "SGML",
					"SortAs": "SGML",
					"GlossTerm": "Standard Generalized Markup Language",
					"Acronym": "SGML",
					"Abbrev": "ISO 8879:1986",
					"GlossDef": {
                        "para": "A meta-markup language, used to create markup languages such as DocBook.",
						"GlossSeeAlso": ["GML", "XML"]
                    },
					"GlossSee": "markup"
                }
            }
        }
    }
}

The same text expressed as XML:

<!DOCTYPE glossary PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
 <glossary><title>example glossary</title>
  <GlossDiv><title>S</title>
   <GlossList>
    <GlossEntry ID="SGML" SortAs="SGML">
     <GlossTerm>Standard Generalized Markup Language</GlossTerm>
     <Acronym>SGML</Acronym>
     <Abbrev>ISO 8879:1986</Abbrev>
     <GlossDef>
      <para>A meta-markup language, used to create markup languages such as DocBook.</para>
      <GlossSeeAlso OtherTerm="GML">
      <GlossSeeAlso OtherTerm="XML">
     </GlossDef>
     <GlossSee OtherTerm="markup">
    </GlossEntry>
   </GlossList>
  </GlossDiv>
 </glossary>

Get Google’s Page Rank from a URL in ASP .NET

Google’s PageRank (PR) is a link analysis algorithm measuring the relative importance. Currently, the significance of PR is a lot lower than one or two years ago. Nevertheless, PR is the only ranking value that is public to all audience (in addition to other simple metrics such as the number of pages). A PR of 10 is the highest around, and 0 the lowest – those sites who don’t even have a PR of 0 are in a kind of sandbox (a special filter to punish the site) or not indexed by Google.

Many webmasters believe their ranking depends on the PR of their pages – this is not true. PR was never the only factor for Google’s ranking, but it was the most important factor. Right now, it’s not.

Google PR Request

A simple HTTP-Request. Here’s the request for http://www.alihamdar.com:

http://toolbarqueries.google.com/search?client=navclient-auto&hl=en&ch=xxxxxxxxx&ie=UTF-8&oe=UTF-8&features=Rank&q=info:http%3A%2F%2Fwww.alihamdar.com%2F

All the paramters are will known except the ch paramter

  • client=navclient-auto (The client requesting)
  • hl=en (The language)
  • ch=xxxxxxxxx (The hash – explained later)
  • ie=UTF-8 (The encoding used for input)
  • oe=UTF-8 (The encoding used for output)
  • features=Rank (The type of request)
  • q=info:http://www.alihamdar.com/ (The link)

ch is a hash value referencing the domain we want to get the PR for. This hashing algorithm was not developed by Google but by Bob Jenkins.

The full code of the hashing and the reading of the rank is as follows:

using System;
using System.Collections.Generic;
using System.Text;  
using System.Text.RegularExpressions;
using System.Net;
using System.IO;
 
namespace GooglePR
{
    class GetPR
    {
        private const UInt32 myConst = 0xE6359A60;
        private static void _Hashing(ref UInt32 a, ref UInt32 b, ref UInt32 c)
        {
            a -= b; a -= c; a ^= c >> 13;
            b -= c; b -= a; b ^= a << 8;
            c -= a; c -= b; c ^= b >> 13;
            a -= b; a -= c; a ^= c >> 12;
            b -= c; b -= a; b ^= a << 16;
            c -= a; c -= b; c ^= b >> 5;
            a -= b; a -= c; a ^= c >> 3;
            b -= c; b -= a; b ^= a << 10;
            c -= a; c -= b; c ^= b >> 15;
        }
        public static string PerfectHash(string theURL)
        {
            url = string.Format("info:{0}", theURL);
 
            int length = url.Length;
            
            UInt32 a, b;
            UInt32 c = myConst;
 
            int k = 0;
            int len = length;
 
            a = b = 0x9E3779B9;
 
            while (len >= 12)
            {
                a += (UInt32)(url[k + 0] + (url[k + 1] << 8) + 
                     (url[k + 2] << 16) + (url[k + 3] << 24));
                b += (UInt32)(url[k + 4] + (url[k + 5] << 8) + 
                     (url[k + 6] << 16) + (url[k + 7] << 24));
                c += (UInt32)(url[k + 8] + (url[k + 9] << 8) + 
                     (url[k + 10] << 16) + (url[k + 11] << 24));
                _Hashing(ref a, ref b, ref c);
                k += 12;
                len -= 12;
            }
            c += (UInt32)length;
            switch (len) 
            {
                case 11: 
                    c += (UInt32)(url[k + 10] << 24); 
                    goto case 10;
                case 10: 
                    c += (UInt32)(url[k + 9] << 16); 
                    goto case 9;
                case 9: 
                    c += (UInt32)(url[k + 8] << 8); 
                    goto case 8;
                case 8: 
                    b += (UInt32)(url[k + 7] << 24); 
                    goto case 7;
                case 7: 
                    b += (UInt32)(url[k + 6] << 16); 
                    goto case 6;
                case 6: 
                    b += (UInt32)(url[k + 5] << 8); 
                    goto case 5;
                case 5: 
                    b += (UInt32)(url[k + 4]); 
                    goto case 4;
                case 4: 
                    a += (UInt32)(url[k + 3] << 24); 
                    goto case 3;
                case 3: 
                    a += (UInt32)(url[k + 2] << 16); 
                    goto case 2;
                case 2: 
                    a += (UInt32)(url[k + 1] << 8); 
                    goto case 1;
                case 1: 
                    a += (UInt32)(url[k + 0]); 
                    break;
                default: 
                    break;
            }
            
            _Hashing(ref a, ref b, ref c);
 
            return string.Format("6{0}", c);
        }
 
        public static int MyPR(string myURL)
        {
            string strDomainHash = PerfectHash(myURL);
            string myRequestURL = string.Format("http://toolbarqueries.google.com/" + 
                   "search?client=navclient-auto&ch={0}&features=Rank&q=info:{1}", 
                   strDomainHash, myURL);
 
            try 
            {
                HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(myRequestURL);
                string myResponse = new StreamReader(
                       myRequest.GetResponse().GetResponseStream()).ReadToEnd();
                if (myResponse.Length == 0)
                    return 0;
                else 
                    return int.Parse(Regex.Match(myResponse, 
                           "Rank_1:[0-9]:([0-9]+)").Groups[1].Value);
            }
            catch (Exception)
            {
                return -1;
            }
        }
 
    }
}

Expect 100 Continue

What is Expect 100 Continue and how does it change the behavior of HttpWebRequest?

In general and according to the HTTP/1.1 W3C RFC 2616 the purpose of the 100 (Continue) status is to allow a client that is sending a request message with a request body to determine if the origin server is willing to accept the request (based on the request headers) before the client sends the request body. In some cases, it might either be inappropriate or highly inefficient for the client to send the body if the server will reject the message without looking at the body. A client MUST NOT send an Expect request-header field with the “100-continue” expectation if it does not intend to send a request body.

Now, having ServicePointManager.Expect100Continue and ServicePoint.Expect100Continue; lets talk about the difference between the two versions of this property. ServicePointManager is the master object that controls the creation and lookup of ServicePoints. As a general rule, properties set on ServicePointManager apply to newly created ServicePoints from that point forward. If you set the property on ServicePointManager after a ServicePoint is created, it will not be propogated to the already existing ServicePoints.

This property simply tells the HttpWebRequest object whether or not to send the “Expect: 100-continue” header with the request . Meaning when this header is sent it tells the server that the client is going to delay sending the body of the request waiting for the server to give the client the OK (a 100 continue response) to upload the data. In current implementations, the HttpWebRequest object waits 350 milliseconds.

The “Expect 100-continue” header with the request is considered important since:

  • The server could redirect the user to a different location, it could require authentication, the connection could have been dropped in between requests, thus avoiding the upload of unnecessary data.
  • The client sets the HttpWebRequest.SendChunked property to true. This means that the client will not tell the server the upload size, but will send the data in chunks. At the beginning of each chunk is information on how big the chunk is and the client sends a zero length chunk to advise the server that there is no more data coming.
  • And because HttpWebRequest keeps a pool of connections to any given server, the connection could be closed by the remote server without the client knowing that the connection has been dropped. And the client cannot safely retry the request if an error occurs beyond a certain point in the request process. If the client has sent even one byte of the upload body, then HttpWebRequest will fail if an error occurs in the connection. If Expect100Continue functionality is enabled, this gives a small window where upload requests can be retried safely. If it is disabled, then an error that occurs when sending the request will cause the entire request to fail.

During my work with different web services on different web servers, I have noticed that server web servers choke on the “Expect 100 Continue”  and send be Error 417 “Expectation Failed”. Investigating the problem, I understood that the exception is raised when using ad-blocking proxies which does not know how to handle or HTTP/1.1 features.

In such cases, you need to disable the Expect 100 continue features by writing the following in your code:

ServicePointManager.Expect100Continue = false;

Which website is taking most of the bandwidth on your IIS web server?

Recently, I had a problem to determine which website on my web server is taking most of the bandwidth. My web server is IIS with logging enabled. The solution is to read the Inbound and Outbounds columns of the log file and sum them to receive the total bandwidth used. This should be done for every website on the web server.

We have two challenges here. The first one is to design a file text reader fast enough to read the inbound and outbound columns in text files (log files) with huge sizes (hundreds of MB). The other challenge is to configure what sites to detect and what IIS Log folders to relate.

For the first challenge, I used an enumerator class. The problem with the usage of a StreamReader is that it reads the entire file in memory, which can be taxing when processing with large files. We can solve this memory problem and mantain the convenience of a loop at the same time by creating a class that implements the IEnumerable interface and exposes its only method, GetEnumerator, which is expected to return an instance of another class which must implement the IEnumerator interface.

The IEnumerator interface exposes only three methods: MoveNext is called at each iteration of the loop, and is expected to return true if the loop should be re-entered, false if the iteration has completed. The Current readonly property is then called to retrieve the value to be used in the current iteration, and finally the Reset method is called when the loop is about to be reentered (in current version of the .NET framework this method is never invoked and can be left empty).

The second challenge is solved by configuring a list containing the IIS log folders associated with their websites. This list can be retrieved from IIS from the Website properties.

Follow

Get every new post delivered to your Inbox.

Join 132 other followers