ISAPI (Internet Server Application Programming Interface) filter

Internet Server Application Programming Interface (ISAPI) is an API developed to provide the application developers with a powerful way to extend the functionality of Internet Information Server (IIS). ISAPI filters always run on an IIS server, filtering every request until they find one they need to process. The ability to examine and modify both incoming and outgoing streams of data makes ISAPI filters powerful and flexible.

Developing a CGI(Common Gateway Interface) program involves creating an EXE with C, C++, and/or Perl programming languages. This EXE file will be executed and terminated for every request received, causing an excessive memory usage, whenever users hit the same page over and over again!

This excessive memory usage that could bring the server completely down, has been solved under ISAPI extensions. An ISAPI extension is a regular DLL file that exposes 3 special functions that is called by the calling process (i.e., IIS) and therefore, will be loaded to memory once, no matter how many clients are going to use it at the same time.

Since the ISAPI extension and the calling process (IIS) live at the same address space, they could contact each other, directly. This means a great potential to bring the whole IIS down, and in some cases, the entire web server! Take a look at the following figure:

Both ISAPI filters and ISAPI extensions can only be developed using C/C++. Visual Studio comes with wizards that make ISAPI development fast and easy.

Uses of ISAPI filters

ISAPI filters can be registered with IIS to modify the behavior of a server. Filters can perform the following tasks:

Change request data (URLs or headers) sent by the client.
Control the user name and password used with anonymous or basic authentication.
Modify or analyze a request after authentication is complete.
Perform custom authentication.
Handle encryption and compression.

NOTE: ISAPI filters DLLs cannot be requested explicitly, like ISAPI extensions can.

References :
http://msdn.microsoft.com/en-us/library/ms524610.aspx
http://www.codeproject.com/KB/ISAPI/isapi_extensions.aspx


Classes of IP Addresses

In our last article on “What is an IP address?”, we had discussed about what is an IP address, structure of an 32-bit IP address or to say an IPv4 address.. We had also mentioned about classes of IP addresses..

In this article we will be discussing on these classes of IP addresses..

But before that let’s recollect that an IP address is simply a unique number assigned to every device on a network.. and the octets of IP address are used to create classes of IP addresses. The Class of the address determines which part belongs to the network address and which part belongs to the node address.

Lets have a look at these IP classes now..

There are five IP classes plus certain special addresses :

Class A Network -- binary address start with 0, therefore the decimal number can be anywhere from 1 to 126. The first 8 bits (the first octet) identify the network and the remaining 24 bits indicate the host within the network. An example of a Class A IP address is 102.168.212.226, where "102" identifies the network and "168.212.226" identifies the host on that network. These addresses are for large networks with many devices.

Class B Network -- binary addresses start with 10, therefore the decimal number can be anywhere from 128 to 191. (The number 127 is reserved for loopback and is used for internal testing on the local machine.) The first 16 bits (the first two octets) identify the network and the remaining 16 bits indicate the host within the network. An example of a Class B IP address is 168.212.226.204 where "168.212" identifies the network and "226.204" identifies the host on that network. These addresses are for medium-sized networks.

Class C Network -- binary addresses start with 110, therefore the decimal number can be anywhere from 192 to 223. The first 24 bits (the first three octets) identify the network and the remaining 8 bits indicate the host within the network. An example of a Class C IP address is 200.168.212.226 where "200.168.212" identifies the network and "226" identifies the host on that network. These addresses are for small networks (fewer than 256 devices).

Class D Network -- binary addresses start with 1110, therefore the decimal number can be anywhere from 224 to 239. Class D networks are used to support multicasting. These addresses are multicast addresses.

Class E Network -- binary addresses start with 1111, therefore the decimal number can be anywhere from 240 to 255. Class E networks are used for experimentation. They have never been documented or utilized in a standard way.

Out of the almost 4.3 billion possible combinations, certain values are restricted from use as typical IP addresses. For example, the IP address 0.0.0.0 is reserved for the default network and the address 255.255.255.255 is used for broadcasts.

Since numbers are usually assigned to internet service providers within region-based blocks, an IP address can often be used to identify the region or country from which a computer is connecting to the Internet. An IP address can sometimes be used to show the user's general location.

The Internet Assigned Numbers Authority (IANA) manages the IP address space allocations globally. IANA works in cooperation with five Regional Internet Registries (RIRs) to allocate IP address blocks to Local Internet Registries (Internet service providers) and other entities.

Before ending this topic, lets also discuss on static and dynamic IPs.

At one time ISPs used to issue one IP address to each user. These are called static IP addresses. Because there are a limited number of IP addresses and with increased usage of the internet, ISPs now issue IP addresses in a dynamic fashion out of a pool of IP addresses. These are referred to as dynamic IP addresses. This also limits the ability of the user to host websites, mail servers, ftp servers, etc. In addition to users connecting to the internet, with virtual hosting, a single machine can act like multiple machines (with multiple domain names and IP addresses).

References:

http://www.howstuffworks.com/
http://en.Wikipedia.org/
http://www.webopedia.com/
http://www.searchwindevelopment.com/


What is an IP Address?

IP address is a very common term that we hear in our everyday life. Lets discuss in detail what exactly an IP address is..

Every device connected to the public Internet is assigned a unique number known as an Internet Protocol (IP) address. This number uniquely identifies the device and distinguishes it from other devices on the network. Networks using the TCP/IP protocol route messages based on the IP address of the destination.

Within an isolated network, you can assign IP addresses at random as long as each one is unique. However, connecting a private network to the Internet requires using registered IP addresses (called Internet addresses) to avoid duplicates.

Now lets see how an IP address looks like..

An IP address consists of four numbers separated by periods (also called a ‘dotted-quad’) and typically looks like 122.169.25.39. To make it easier for us (humans) to read and remember, IP addresses are normally expressed in decimal format as a "dotted decimal number" like the one above. But computers communicate in binary form.

Look at the same IP address in binary : 00111010.10101001.00011001.

The four numbers in an IP address are called octets, because they each have eight positions when viewed in binary form. If you add all the positions together, you get 32, which is why IP addresses are considered 32-bit numbers. Since each of the eight positions can have two different states (1 or 0) the total number of possible combinations per octet is 28 or 256. So each octet can contain any value between 0 and 255. Combine the four octets and you get 232 or a possible 4,294,967,296 unique values !

Now, this design of IP as a 32-bit number was developed by the original designers of TCP/IP and this system, now named as Internet Protocol version 4 or IPv4 is still in use. However, due to the enormous growth of the Internet and the resulting depletion of the address space, a new addressing system (IPv6), using 128 bits for the address, has also been developed. Both the systems of IP addressing are being used.

Continuing with the structure of IP address.. The octets, about which we were discussing, serve a purpose other than simply separating the numbers. They are used to create classes of IP addresses that can be assigned to a particular business, government or other entity based on size and need. The octets are split into two sections: Net and Host. The Net section always contains the first octet. It is used to identify the network that a computer belongs to. Host (sometimes referred to as Node) identifies the actual computer on the network. The Host section always contains the last octet.

The Class of the address determines which part belongs to the network address and which part belongs to the node address. All nodes on a given network share the same network prefix but must have a unique host number.

There are five IP classes plus certain special IP addresses..about which we will be discussing in our next article..

References:

http://www.howstuffworks.com/
http://en.Wikipedia.org/
http://www.webopedia.com/
http://www.searchwindevelopment.com/


Globalization and Localization

Ms. Asha Bora has done some studies on Globalization and Localization.. Lets see what she has to say..

Globalization and localization are very important features of .Net framework, which is very useful and about which every programmer should be aware of while creating an application. If I want my application to be used by everyone then I have to make my interface in a language which everyone can understand or say in a global language. But at the same time it is not possible that everyone in the world knows a particular language. So, in order to make those people use the application, I have to publish it in their regional language or say in their local language, this is known as localization .

From the introduction of the article you must have understood the basic meaning of globalization and localization. Now let’s see a proper definition of it in terms of a programmer.

This very important feature is used by .Net to make our programs universal. Now if we talk in term of programming then GLOBALIZATION can be defined as the process of designing and developing an application that function for multiple cultures and regions, irrespective of the language and regional differences and LOCALIZATION is the process of customizing your application for a given culture and locale. It consists primarily of translating the user Interface according to a culture. Culture will decide date display settings (like, mm/dd/yyyy or dd/mm/yyyy), currency display formats etc.

Now, the process by which we can make sure that our program will be localized is known as Internationalization or Globalization. In simpler terms, Globalization can be defined as the set of activities which will ensure that our program will run in regions with different languages and cultures.

Thus, globalization is related to intrinsic (basic) code changes to support such changes we use Resource files etc. Whereas, localization is the process of using a particular culture and regional info so that the program uses the local languages and culture. This means translating strings into a particular local language. This covers putting language specific strings in the resource files. Globalization starts in the main construction phase along with the code development. Localization generally comes later.

Now let’s see how we define the culture and region code.

We all know that languages depend upon the geographical location. For example, French is spoken in France as well as in Canada (besides many other countries). But linguistically speaking, Canadian French is quite different from French spoken in France. Similarly, there are linguistic differences between US English and British English. Therefore, the language needs to be associated with the particular region where it is spoken, and this is done by using locale (language + location).

For example
: fr is the code for French language. fr-FR means French language in France. So, fr specifies only the language and FR specifies the region France whereas fr-FR is the locale. Similarly, fr-CA defines another locale implying French language and culture in Canada. If we use only fr, it implies a neutral culture (i.e., location neutral).

Now, in order to change the current culture, we have to change two properties of the CultureInfo class- UICulture and Culture.

ASP.NET can set the UICulture and Culture properties for the page to the language and culture values that are passed by the browser. Alternatively, you can set the UICulture and Culture properties explicitly, either declaratively or in code. You can also set the values declaratively in
Web.config file under the property and these two properties can be set using the overloaded constructor of the class and then we can use this class to change the culture of the currently executing program.

UICulture: gets/sets the user interface culture for the currently executing thread. This property helps the runtime to load the resource strings from a specific resource. This property can take neutral cultures as well as locales.
  • Thread.CurrentThread.CurrentUICulture = new CultureInfo(“fr”); OR
  • Thread.CurrentThread.CurrentUICulture = new CultureInfo(“fr-CA”);
Culture: gets/sets the region specific culture and formats of currency, dates etc. This needs language as well as location.
  • Thread.CurrentThread.CurrentCulture = new CultureInfo(“fr-CA”); // we have given locale
  • Thread.CurrentThread.CurrentCulture = new CultureInfo(“fr”); // wrong, will not work
In my next article I will talk about “How to implement Globalization in our application”.

References:

  • http://msdn.microsoft.com/en-us/library/ms227427.aspx
  • http://www.codeproject.com/Kb/aspnet/localizationByVivekTakur.aspx

<Pre> Tag in HTML

There are many times when you need to show some sample C#, or java or any other code in your web page. For proper understanding and readability, these kind of code snippets need proper formatting.

But..by default, browsers collapse all the spacings, tabs and line breaks.

So, for properly formatting such stuffs, what do you do ??

One way is to go through all the lines, and at every occurance.. manually replace the white spaces with , line breaks with <br/> tags. While writing loops, for every ‘ < ’ and ‘ > ’ signs write &lt; and &gt;, etc etc.

Don’t you think all this is a real pain ??

A simple solution to this problem is using HTML pre tag.

Pre tag simply displays the enclosed pre-formatted text. This means that it directs the web browser to render the section of text contained within pre tag, exactly as it is..including the line breaks and white spaces. The <pre> tag is supported in all major browsers.

When you place any paragraph with preformatted text such as some poetry or some lines of code.. directly inside the Body tag of HTML, browser ignores the spacing, tabs and line breaks used in its text formatting. This is because a web browser interprets your html document as being one long line. Sure, you may have tabs and line breaks in notepad aligning your content so it is easier to read for you.. but your browser ignores those tabs and line breaks. So, if you will enclose that preformatted text with HTML pre tag <pre> it will not ruin the formatting of the text and will display with its formatting preserved.

pre tag is a container tag, which means it begins with an opening <pre> element and ends with closing </pre> element. The common attributes such as id, style, class, title etc and the events such as onclick, onmouseover, ondbclick etc as common to most html elements..are applicable to pre tag as well.

This element can be contained inside other elements such as html "applet", "blockquote", "body", "button", "center", "del", "dd", "div", "fieldset", "form", "iframe", "ins", "li", "map", "noframes", "noscript", "object", "td", and "th", etc.

And it may contain any other inline elements except "img", "object", "applet", "big", "small", "sub", sup". "font", and "basefont".

The PRE element is handy for showing program code or part of file content as in the example below:

<pre>
function sayHello(){

int i =0;

for(i=0; i <=10; i++){
System.out.println("Hello World !!");
}
</pre>

You will see the output in your web page as :
function sayHello(){

int i =0;

for(i=0; i <=10; i++){
System.out.println("Hello World !!");
}
NOTE : By default, Pre tag displays the pre-formatted text in Courier font type.

A very good example for using pre tag is posting articles using blogger interface. Formatting the articles using blogger UI was a pain for me.. Pre tag really saved my life..


References :
•   http://htmlhelp.com/reference/html40/block/pre.html
• http://www.codetoad.com/html/text/pre_tag.asp

• http://www.htmlquick.com/reference/tags/pre.html

http://programming.top54u.com/post/HTML-Pre-Tag-for-Preformatted-
Text.aspx





RSS Feeds

RSS the most familiar abbreviation used by almost all bloggers, webmasters, News Providers and readers. This article presents our readers a breif introduction about Rich Site Summary or Really Simple Syndication  (RSS)

*Syndicationpublish or broadcast simultaneously in a number of media (taken from www.askoxford.com)

RSS is a format for syndicating news and the content of news-like sites, including major news sites like news.google.com, technology blogs like www.labnol.org  and personal weblogs. 
But it's not just for news. Pretty much anything that can be broken down into discrete items can be syndicated via RSS: the "recent changes" page of a wiki, the profile updates of your friends on Orkut, newly posted articles on blogs(e.g. www.blog.TechYoddha.com) and even the revision history of a book.


Why Should one have feeds?
  • It increases traffic to your site.
  • It builds brand awareness for your site.
  • It can help with search engine rankings.
  • It helps cement relationships within a community of sites.
  • It improves the site/user relationship.
  • With additional technologies, it allows others to give additional features to your serviceupdate-notification via instant messaging, for example.
  • It makes the Internet an altogether richer place, pushing semantic technology along and encouraging reuse. Good things happen when you share your data.
  • It gives you a good excuse to play with some cool stuff. {like i did by having a personal channel of feeds :-) }
  • By reducing the amount of screen-scraping of your site, it saves wasted bandwidth.


Creation of RSS:
It is just an XML file that you should have for creating an RSS feed.
Else everything is the beauty of the Feed Reader that you have viz. on Mobile, in Browsers, desktop application to read RSS feeds etc.


Steps:
  1. Create a valid XML file with .xml extension
  2. host it at some server e.g.  your public_html directory of your domain website
  3. access the file with a Feed Reader ( e.g. www.TechYoddha.com/ty.xml)
There are other 100s of RSS providers available to create your RSS feeds automatically for your blog posts (e.g FeedBurner, FeedBlitz etc.)


Contents of XML file:
  1. xml tag
  2. rss tag
  3. channel tag
  4. title tag
  5. link tag
  6. description tag
  7. item tag
  8. title tag
  9. link tag
  10. description tag


Sample Feeds:
  1. http://www.ndtv.com/convergence/ndtv/rssnat.asp
  2. http://www.hindu.com/rss/nushdline.xml
  3. http://feeds2.feedburner.com/TechYoddha


References: