1

IIS seems to be an application that listens for incoming connections, parses the data sent there as HTTP requests, and maps request urls to directories based on a site an application and a virtual directory, and then does something based on the file present (or not present) on that location.

MVC meanwhile takes an HTTP request, routes it to a controller, which generates a HTTP response and sends it back.

It seems MVC handles exactly the same part of the network stack as IIS does, modulo the network endpoint (and that is a fairly trivial part of code, the hard work is done by the underlying OS part of the network stack on TCP level), but an MVC site is hosted "in" IIS somehow.

But IIS is a massive program. It must do something other than connection management. What does it actually do, and what do all these concepts ("site", "application", "virtual directory") mean in the context of a project that seems to replace their function in the first place?

Martijn
  • 11,964
  • 12
  • 50
  • 96
  • I've been reading the documentation for days, but I still have no idea what IIS does. Would you have a suggestion for a site which fits the scope of this question? – Martijn Jun 12 '15 at 11:09

1 Answers1

0

MVC nor IIS do any port listening or HTTP parsing. That's http.sys's job, which is the HTTP Server API. See MSDN: HTTP Server API, how exactly does http.sys work, Introduction to IIS Architectures, and especially HTTP Request Processing in IIS.

IIS adds a lot of functionality on top of http.sys, apart from configuration and management: handlers and modules. Those allow you to run any kind of code to generate or alter a response for an HTTP request.

Key point here are handlers. They decide what particular piece of software will be invoked to handle a request, or they handle the request themselves. You have static resource handlers to handle for example requests for image, css and js files. There's also the ASP.NET handler that handles .aspx requests, see Introduction to HTTP Handlers.

Now MVC works hand in hand with a routing handler. All that the MVC handler does is look at the URL and your routing configuration, and then choose which controller method to invoke to generate the response for the request.

Community
  • 1
  • 1
CodeCaster
  • 147,647
  • 23
  • 218
  • 272
  • So if I understand you correctly, IIS is a program that interprets a configuration (which probably includes the "sites", "applications" and "virtual directories"), and based on that configuration tells http.sys which handler to invoke. A handler is a piece of software that creates a http response when given a http request, and gives that back to http.sys. An MVC project is an example of a handler. Is that it? – Martijn Jun 12 '15 at 11:39
  • Not entirely: handlers are an IIS concept, not an http.sys one. Also, all the MVC handler does is execute the assemblies from your MVC project. An MVC project is not a handler in itself. – CodeCaster Jun 12 '15 at 11:51
  • so, to recap: http.sys receives data, and parses it to a http request. It gives it to IIS. IIS is configured to handle the request with the MVC handler through some configuration somewhere. The MVC handler is an assembly that is configured somewhere (else?) to load the assemblies of my project, and call those to determine which controller to call, and then calls that controller. The MVC handler receives back the http response, hands it back to IIS, and IIS hands it back to http.sys, which writes it back to the network socket? – Martijn Jun 12 '15 at 12:24
  • and in this context "installed" means loaded into the .NET runtime and passed the configuration values? – Martijn Jun 12 '15 at 12:46