1
在
期間
任何Application_BeginRequest
Global.asax
或System.Web.Services.WebService
事件,有沒有一種可靠的方法來實例化或檢查使用反射的預期的Web服務方法?我需要確定被調用的Web服務中屬性的值。如何在Application_BeginRequest中使用反射來即時使用Web服務方法?
我很確定必要的信息在HttpContext.Current.Request
可用,但我對反射語法不夠熟悉。
GLOBAL ASAX
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
Dim InboundRequest As HttpRequest = HttpContext.Current.Request
'ASSUMING REQUEST IS FOR DemoService.asmx/ExampleMethod'
'NEED CODE HERE TO DETERMINE '
'WHAT THE VALUE OF THE "ScriptMethod" ATTRIBUTE IS'
End Sub
WEB SERVICE
<ToolboxItem(False), ScriptService()> _
Public Class DemoService
Inherits System.Web.Services.WebService
<WebMethod(), ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
Public Function ExampleMethod()
Return "Hello World"
End Function
End Class
VB.Net或C#的答案是受歡迎的,我可以爲neccessary
你有覆蓋該事件的例子嗎? –
你可以把它放在global.asax中。它就像BeginRequest事件 –
您能否更具體地瞭解我在'Application_PreRequestHandlerExecute'期間訪問的內容,我無法在'Application_BeginRequest'中訪問? EventArgs仍然是空的,我沒有看到上下文或請求中的任何特殊內容 –