我想知道ASP.NET看起来像什么“干净”.例如,我想在ASP.NET上构建自己的框架,我不知道应该包含哪个程序集. 所有讨论ASP.NET的书都描述了WebForms或MVC,但没有一本解释ASP.NET层. ASP.NET的哪一部
所有讨论ASP.NET的书都描述了WebForms或MVC,但没有一本解释ASP.NET层.
ASP.NET的哪一部分在下图中是什么意思?
WebForms和MVC都是通过处理程序实现的,请参阅MSDN上的 ASP.NET Page Handler和 MvcHandler Class.Handlers(MSDN: Introduction to HTTP Handlers)是使用ASP.NET的最轻量级方法.您可以访问HttpRequest实例,该实例知道有关要知道的请求的所有内容.
在处理程序中,您读取此HttpRequest,应用您的应用程序逻辑并通过HttpResponse成员实例写入结果,该实例是ProcessRequest(HttpContext context)中IHttpHandler的HttpContext参数具有:
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; }
}
}
}
很多ASP.NET(如果不是全部)都存在于System.Web命名空间中.
