如何设置httpsodule中的httphandler以获取poject中不存在的静态文件。
例如:如果客户端请求不在我的项目中的名为abc.xml的文件,我需要从我的httpmodule添加处理程序并向客户端发送一些响应我该怎么做。从httpmodule添加后,我的处理程序不会被调用。
我的HttpModule代码如下:
Public Sub Context_BeginRequest(sender As Object, e As EventArgs)
Dim Application As HttpApplication = CType(sender, HttpApplication)
Dim CustomHandler As StorageHandler = New StorageHandler()
Application.Context.Handler = CustomHandler
End Sub
customHandler中的processrequest不会被执行。
答案 0 :(得分:0)
花了5小时后,明白了。
需要使用RemapHandler,
Application.Context.RemapHandler(CustomHandler)
而不是
Application.Context.Handler = CustomHandler