IIS- Still learning!

Handshake
Handshake @Image courtesy of pat138241/ FreeDigitalPhotos.net

IIS- Still learning!

Welcome to CodeSpread!

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.

Author: hershey

A passion for knowledge drives me to do programming, A passion for programming drives me to create something different, A passion for creation drives me to spread the knowledge.

Share This Post On

0 Comments

  1. nice superb explaination

    Post a Reply
  2. thanks for the tutorial
    I am having a problem.
    The feature “Create SQL server database” isn’t available , I can’t select it.
    Can you help, please ?

    Post a Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

More from CodeSpread:

  • IIS Pre-ArticleIIS Pre-ArticleI thought of sharing few articles on IIS so when I started my mission, I realized that there should be some basic tasks related to IIS which needs to be done by the user before diving deep into IIS...
  • How to add alias and create virtual directory?How to add alias and create virtual directory?There is a term very famous in IIS world 'virtual directory', but before discussing a virtual directory, we should be familiar with the term 'alias'.By definition, an object can have alternative na...
  • IIRF.ini for URL rewritingIIRF.ini for URL rewritingWe often hear the terms like URL rewriting or friendly URLs. There are many techniques available to achieve it and we will discuss one of those today, IIRF. What is URL rewriting? Before we try t...
  • How to create database with SQL express bundled with Visual Studio?How to create database with SQL express bundled with Visual Studio?Yes, Visual studio comes bundled with a copy of SQL express edition which gets installed during visual studio installation. These steps are required to create database with SQL express bundled w...
  • Windiff saved my effort. How it is useful?Windiff saved my effort. How it is useful?While working with TFS [Team foundation server],we get used of the compare feature to compare the 'local version', 'server version','workspace version'. We had some similar situation when we rec...
  • App_Offline Updates in Webdeploy V3 and Visual Studio 2013App_Offline Updates in Webdeploy V3 and Visual Studio 2013Please refer Don’t Mess with App_Offline article to see the usefulness of App_Offline. Treat the below article as an update to the concepts and basics shared earlier. After going through visual ...
  • How to create a MVC 2 Project in VS2010?How to create a MVC 2 Project in VS2010?How to create a MVC 2 Project in VS2010? 1. Open VS2010. 2. Select File -> New Project. 3. Select Visual C# -> Web -> ASP.NET MVC 2 Empty Web Application. Name it as MyMvcApplicat...
  • Time Out: Not a Technical postTime Out: Not a Technical postTaking my time-out from technical world for once and sharing a regular joke in the form of  this comic with you. There is no harm in showing funny side also sometimes. wat say!!