1 / 17

Hosting ASP.NET

Hosting ASP.NET. Ted Neward Neward & Associates blogs.tedneward.com. Credentials. Who is this guy? Independent consultant Author C# in a Nutshell (O’Reilly, with Drayton, Albahari, 2001) Server-Based Java Programming (Manning, 2000)

mae
Download Presentation

Hosting ASP.NET

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Hosting ASP.NET Ted NewardNeward & Associatesblogs.tedneward.com

  2. Credentials • Who is this guy? • Independent consultant • Author • C# in a Nutshell (O’Reilly, with Drayton, Albahari, 2001) • Server-Based Java Programming (Manning, 2000) • SSCLI Essentials (O’Reilly, with Stutz, Shilling, 2003) • Effective Enterprise Java (Addison-Wesley, 3Q 2003) • Papers at http://www.neward.net • Blog at http://blogs.tedneward.com

  3. A Brief History • HTTP takes over the world • HTTP & HTML used to be synonymous • CGI begins the “dynamic HTML” approach • ISAPI becomes a “lighterweight CGI” • ASP becomes higher-level ISAPI • And everybody lived happily ever after

  4. A Brief History, part II • Well, OK, not that last part • ASP is nice, but has some flaws • Robustness: in-proc approach (at first) • HTTP “changed”, or what we expect of it did • IIS presents some issues, too

  5. Issues • Current dependency on IIS has issues • IIS is “more” than just HTTP • WebServices want to keep overhead “light” • IIS represents huge security liability • ASP, for all its goodness, is “tied” to IIS • ASP really isn’t using IIS all that much • ASP depends on COM—apartments, etc

  6. ASP.NET • Latest release of ASP • Also known as the “HttpRuntime” • Provides managed extensions to HTTP • .ASPX pages == content-driven response • .ASHX pages == code-driven response • .ASMX pages == WebServices-driven • All behind IIS?

  7. HttpRuntime • HttpRuntime entirely divorced from IIS • Cassini (part of Saturn): C# HTTP Server • Hosts HttpRuntime directly—no IIS! • Key: System.Web.Hosting namespace

  8. System.Web.Hosting • Underdocumented API for HttpRuntime • Create HttpRuntime AppDomain • ApplicationHost.CreateApplicationHost(…) • Pass HttpWorkerRequest into host • Key lies in HttpRuntime.ProcessRequest()

  9. Minimal Host • Barebones HttpRuntime host:

  10. Minimal Host • Run by passing “requests” on cmd line

  11. Implementation • What’s going on here? • CreateHost spins off new AppDomain • Host must be MarshalByRefObject as a result • Host lives in new AppDomain instance • Multiple hosts, multiple AppDomains • Host configured with physical dir and URL “path”

  12. Implementation • Once host is created • Host must somehow receive request • Host’s responsibilities: • Call HttpRuntime.ProcessRequest • Pass in a HttpWorkerRequest-implementing object • Object contains parameters to request • SimpleWorkerRequest a simple example • HttpRuntime takes over from here • Complete support: web.config, handlers, etc

  13. HttpWorkerRequest • Class representing request/response • Host’s responsibility for extracting all info • SimpleWorkerRequest provides basic info • Real-world implementation would extract data from port, etc. • Also provides response buffer for output • SimpleWorkerRequest uses TextWriter passed in constructor

  14. HttpRuntime • What’s not there • CGI support • MIME types support • No ASP support • Nothing configured from IIS metabase • What is there • Everything specified in web.config • Full .NET environment (GAC, etc)

  15. Warning • Created host limitations • Host assembly must be in either: • GAC • “bin” subdirectory of current directory • HttpRuntime hard-configures this • No documented way to change this

  16. Motivation • So what? Why do I care? • Cassini’s not “production-quality” • Intended as lightweight server for Saturn • IIS 5, 6, 7 full-featured, HTTP cracking in kernel • Why not use that?

  17. Motivation • Why you should care • IIS not appropriate in all situations • .NET more portable than COM (Rotor, Mono, Portable.NET, etc) • Lightweight front for WebServices • Lightweight server for debugging • Spelunking

More Related