Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Tagged as

IIS- Still learning!

, 19 Dec 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
Whenever we receive some error which is related to IIS, we just jump on internet as we lack the basic concepts of IIS and i can definitely say that we almost ignore IIS and focus ourselves on development and coding. Then Why not learn IIS today? I would share my knowledge and request all of.....Rela

Whenever we receive some error which is related to IIS, we just jump on internet as we lack the basic concepts of IIS and i can definitely say that we almost ignore IIS and focus ourselves on development and coding. Then Why not learn IIS today? I would share my knowledge and request all of you to share your bit or you can send your articles/abstracts to admin@codepsread.com also.

What is IIS?

IIS- Wikipedia says “Internet Information Services (IIS) – formerly called Internet Information Server – is an app server application and set of feature extension modules created by Microsoft for use with Microsoft Windows.” Just check out the terms, application, set of feature extension modules, this means it is a program or component running on a windows platform which provides us all the features or additional features required to host our website.

In real world, a regular machine running a windows server operating system is equivalent to a ‘server’ and if IIS is installed on this server and sites are hosted on IIS, then this server will be equivalent to web server. Simple enough!

It is a Microsoft product so it is tightly coupled to Windows platform and second it was targeted to compete in Internet server market with already existing giants like Apache, so it has captured all the existing features and provided additional features also.

What is the role of IIS?

Role is played by a character in a story, IIS is our character here, and the story is Application Life Cycle. In this story, there are many characters and IIS is the first and major character which plays host to any request coming to it and sends it to the processing pipelines.

Request sent by client | Request received by II

Figure shows communication of client and server over HTTP , server receives requests on Port 80 and if the protocol is HTTPS, port will be 443. Although, I have skipped the DNS part but we will cover it sometime in future.

How IIS looks like?

Go to Windows->Run->type inetmgr [Before that check whether IIS is installed or enabled on your system, Refer this article]

IIS-Panel

IIS Panel has three groups: ASP.Net, IIS and Management. Out of these 3, two are visible in above image.

  • ASP.NET Includes tasks related to managing tasks related to ASP.NET like connection strings,SMTP email etc.
  • IIS Includes tasks related to managing sites and applications  like Modules, Handlers etc.
  • Management Includes tasks related to configuring administrative roles, delegation, and remote administration.

How it works?

Once the request is received by IIS, it follows the below process.

  • IIS runs a process, inetinfo.exe, which processes the request as per its state like static or dynamic. Request for static resources for ex: HTML pages, Images, Javascript files, XML will be directly handled by the server and and sent back as a response. This process is quite fast also.
  • Request for Dynamic resources like  web pages(.aspx), custom extensions, web service(.asmx), handlers(.ashx), global asax(.asax) files will require additional processing, which will be done by ISAPI extensions , where ISAPI stands for Internet Server Application Programming Interface. ISAPI extensions are filters  which requires relation between ISAPI filter and files extension, that is, when a request for such a file arrives, IIS handles it to the corresponding ISAPI filter. for ex: When a request for .aspx arrives, then IIS looks for the mapping of “aspx” extension which is mapped to “aspnet_isapi.dll” and hence requests for an aspx page to IIS will be given to aspnet_isapi extension. Another example is When a request for .asmx arrives, then IIS looks for the mapping of “asmx” extension which is also mapped to “aspnet_isapi.dll” and hence requests for an asmx page to IIS will be given to aspnet_isapi extension.
  • Request is passed to .Net runtime, where a lot of important things happen. For the very the first request ,ApplicationManager creates an application domain. Application domains provide isolation between applications for global variables, and allow each application to be unloaded separately. [msdn]
  • ApplicationManager manages already running requests in the pipeline processing and routing any new request coming in to the new AppDomain.
  • Within an application domain, an instance of the class named Hosting Environment is created, which provides access to information about the application such as the name of the folder where the application is stored.[msdn]. This can be appropriately understood as the play ground for all the execution.
  • After that, ASP.NET creates and initializes core objects such as HttpContext, HttpRequest, and HttpResponse.The HttpContext class contains objects that are specific to the current application request, such as the HttpRequest and HttpResponse objects. The HttpRequest object contains information about the current request, which includes cookies and browser information. The HttpResponse object contains the response that is sent to the client, which includes all the rendered output and cookies.[msdn]
  • The application is started by creating an instance of the HttpApplication class. If the application has a Global.asax file, ASP.NET instead creates an instance of the Global.asax class that is derived from the HttpApplication class. It then uses the derived class to represent the application.[msdn]

Note: The first time that an ASP.NET page or process is requested in an application, a new instance of the HttpApplication class is created. However, to maximize performance, HttpApplication instances might be reused for multiple requests.

Once HttpApplication pipeline is ready, request goes through a number of events and developer has more control then.

What we have not discussed?

There are few items which require more attention and were not included in above flow to make it simple.

Worker Process:  Worker Process normally referred as w3wp.exe is responsible for running ASP.Net application in IIS. The worker process does the real handling, delivery, and response to the incoming request for a particular Web site.This process is responsible to manage all the request and response that are coming from client system. Each website is associated with a worker process.

Application Pool: We can see in above image,on left hand side, we have Application Pools and Sites available. Each Web site runs in an application pool, which is a named worker process and logical memory allocation which can contain one or more websites or applications . Application pools provides isolation between sites and applications from each other .In other words, Application pools can be termed as an individual sets of IIS worker processes which ensures security and reliability. If there is an issue with a particular application pool then it would not affect other websites running in different application pool.

Application Pool Identities: Each worker process and associated application pool runs in the security context of an application pool identity. The default identity for both default application pools is Network Service.The identity is a user or service account used to run the worker process and application pool. We do have option to select the identities but one error we regularly see is due to running the application under local user identity so the solution is to add it to the IIS_IUSRS group, which assigns the necessary permissions and privileges to allow the account to function as an IIS application pool identity.

Managed Pipelines: There are two managed pipeline mode available for processing requests of ASP.NET applications-

  • Classic
  • Integrated

When classic mode is selected, IIS processes the requests in an application pool by using separate processing pipelines for IIS and ISAPI. This means that the ASP.NET request pipeline is separate from the Web server pipeline. Modules apply only to requests that are routed to the ASP.NET ISAPI extension. If the file-name extension of the requested resource type is not explicitly mapped to ASP.NET, ASP.NET functionality is not invoked for the request because the request is not processed by the ASP.NET runtime.[msdn]

When Integrated mode is selected, IIS processes the requests in an application pool by using single processing pipeline for IIS and ISAPI. The integrated pipeline receives a request and the request passes through stages that are common to all requests.For example, even though the .htm file-name extension is not explicitly mapped to ASP.NET, a request for an HTML page still invokes ASP.NET modules. This enables us to take advantage of ASP.NET authentication and authorization for all resources.[msdn]

There are so many features or options available in IIS which i always wanted to learn, we will learn most of these features in subsequent articles.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Himanshu DS
Web Developer CodeSpread.com
India India
I am a regular developer working on c#,asp.net,sql,cms,digital marketing related sites. Through my blog, I am showing the non-technical part of our daily technical terms and processes which can be used to describe it to a layman.Sometimes I write basic technical posts also.
Follow on   Twitter

Comments and Discussions

 
GeneralMy vote of 3 Pingrouparid0814-Jan-13 0:03 
GeneralRe: My vote of 3 PinmemberHimanshu DS16-Jan-13 0:53 
Thanks! But why my article is downvoted. Am I missing something here?

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411019.1 | Last Updated 19 Dec 2012
Article Copyright 2012 by Himanshu DS
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid