vmalyuta vmalyuta - 1 year ago 136
ASP.NET (C#) Question

Writing ASP.NET frameworks other than WebForms or MVC?

I want to know what "clean" ASP.NET looks like. For example, I want to build my own framework on ASP.NET, and I don't know what assembly I should include.

All books discussing ASP.NET describe either WebForms or MVC, but none explain the ASP.NET layer of things.

What part of ASP.NET is meant in below picture?


Answer Source

Both WebForms and MVC are implemented through a handler, see the ASP.NET Page Handler and MvcHandler Class on MSDN.

Handlers (MSDN: Introduction to HTTP Handlers) are the most lightweight way to utilize ASP.NET. You get access to an HttpRequest instance that knows everything about the request there is to know.

In a handler, you read this HttpRequest, apply your application logic and write the result throught the HttpResponse member instance that an IHttpHandler's HttpContext parameter in ProcessRequest(HttpContext context) has:

namespace HandlerExample
   public class MyHttpHandler : IHttpHandler
      // Override the ProcessRequest method.
      public void ProcessRequest(HttpContext context)
         context.Response.Write("<H1>This is an HttpHandler Test.</H1>");      
         context.Response.Write("<p>Your Browser:</p>");
         context.Response.Write("Type: " + context.Request.Browser.Type + "<br>");
         context.Response.Write("Version: " + context.Request.Browser.Version);

      // Override the IsReusable property.
      public bool IsReusable
         get { return true; }

A lot of ASP.NET, if not all, lives in the System.Web namespace.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download