Vb.net 不明白为什么我的方法没有被调用
我的站点使用了几个文件处理程序,它们都有重复的代码。为了整理,我创建了一个通用基类,它们都可以继承:Vb.net 不明白为什么我的方法没有被调用,vb.net,oop,Vb.net,Oop,我的站点使用了几个文件处理程序,它们都有重复的代码。为了整理,我创建了一个通用基类,它们都可以继承: Public MustInherit Class HandlerBase Implements System.Web.IHttpHandler, System.Web.SessionState.IRequiresSessionState Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReus
Public MustInherit Class HandlerBase
Implements System.Web.IHttpHandler, System.Web.SessionState.IRequiresSessionState
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
Public Overridable Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
RequestHandler(context)
End Sub
Protected Overridable Sub RequestHandler(ByVal context As HttpContext)
Select Case context.Request.HttpMethod
Case "GET"
GetFile(context)
Case "POST"
UploadFile(context)
Case "DELETE"
DeleteFile(context)
Case Else
context.Response.ClearHeaders()
context.Response.StatusCode = 405
End Select
End Sub
Protected MustOverride Sub GetFile(ByVal context As HttpContext)
Protected MustOverride Sub UploadFile(ByVal context As HttpContext)
Protected MustOverride Sub DeleteFile(ByVal context As HttpContext)
end class
我的两个处理程序在继承基类后工作得很好,但其中一个似乎根本没有启动。唯一的区别是此处理程序覆盖RequestHandler:
Protected Overrides Sub RequestHandler(ByVal context As HttpContext)
Select Case context.Request.HttpMethod
Case "GET"
GetFile(context)
Case Else
context.Response.ClearHeaders()
context.Response.StatusCode = 405
End Select
End Sub
我访问处理程序,并且从未在base中调用ProcessRequest,也没有在RequestHandler中发现这是在fiddler中检查请求后的一个小错误:
Protected Overrides Sub DeleteFile(ByVal context As HttpContext
Throw New NotImplementedException()
End Sub
缺少参数的结束括号。我将投票结束这场辩论