johnny 5
johnny 5

Reputation: 21033

How does IIS Know how to start .NET Web Application

I'm trying to understand how IIS knows how to start my ASP.Net Web Application My understanding so far is that, when creating a web application we create a Web.Config which defines how IIS will start it's process

So We have a Web Config

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true">
    <add name="LogRequests" type="BDBPayroll.Apps.API.Web.Shared.HttpModules.LogRequestsHttpModule, BDBPayroll.Apps.API.Web.Shared" />
    <add name="MiniProfiler" type="BDBPayroll.Apps.API.Web.Shared.HttpModules.MiniProfilerHttpModule, BDBPayroll.Apps.API.Web.Shared" />
  </modules>
  <handlers>
    <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
    <remove name="OPTIONSVerbHandler" />
    <remove name="TRACEVerbHandler" />
    <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
  </handlers>
</system.webServer>

And The Global Asax:

public class WebApiApplication : WebApiHttpApplication<WebModule>
{
    protected override void Configure(HttpConfiguration config)
    {
        config.Filters.Add(new Filters.ContextResolverFilter());
        config.Filters.Add(new ValidateModelAttribute());
        config.Filters.Add(new PaginationFilter());

        GlobalContext<JsonFormatterRule>.Instance.SetDefaultJsonFormatter(config);


    }
    //...
}

Since IIS can run multiple applications e.g php, .net etc, How does IIS Know from the Web Config To run the Global Asax.

My guess is that it looks up the application type from the web config, and then searches for WebApiHttpApplication, Does anybody have any more information on this process?

Upvotes: 0

Views: 606

Answers (1)

Brando Zhang
Brando Zhang

Reputation: 28397

Since IIS can run multiple applications e.g php, .net etc, How does IIS Know from the Web Config To run the Global Asax.

My guess is that it looks up the application type from the web config, and then searches for WebApiHttpApplication, Does anybody have any more information on this process?

As far as I know, if use send the request to the IIS.

After handling the http request by http.sys, IIS will move this request to the w3wp.exe to handle it.

Since IIS could only handle htm or html static page, IIS will use ISAPI to handle the page which IIS couldn't handle.

ISAPI is a kind of extention handler to handle different kinds of pages like php, aspx, cshtml or something else.

You could find it from IIS manager console handler mapping icon.

Image as below:

enter image description here

enter image description here

The IIS will send the request to right http hanlder according to its extension. The handler moudule(e.g asp.net isapi) will load the CLR and web application(include the globalasax) to handle the request.

Upvotes: 1

Related Questions