我正在尝试实现一个IRouteHandler,它返回一个完全实现的IHttpHandler。
因此,当我实现IRouteHandler的唯一一种方法时,我得到了RequestContext参数。
internal class MyRouteHandler : IRouteHandler, IRequiresSessionState { public IHttpHandler GetHttpHandler(RequestContext requestContext) { return new MyHandler(requestContext); } }
稍后,当请求传入实现的ProcessRequest中的IHttpHandler时:
internal class MyHandler : IHttpHandler, IRequiresSessionState { private readonly RequestContext _requestContext; public MyHandler(RequestContext requestContext) { _requestContext = requestContext; } public void ProcessRequest(HttpContext context) { // How is this HttpContext instance differs from the RequestContext instance? // Do I need both? } }
此HttpContext实例与RequestContext实例有何不同?就我而言,我需要两者吗?(在IRouteHandler实现中,我什么也不做。创建的IHttpHandler将为所有请求提供服务。