如何在 ServiceStack VB.net 中提取 URL 参数?
例如查询网址:
http://localhost:3318/api/ActionName/?callback=cb&format=json&SomeParam1=19-11-2012&SomeParam2=123123
仅供参考,我正在使用 jQuery AJAX 发出请求。
全球.aspx
Public Class Global_asax
Inherits System.Web.HttpApplication
Public Class HelloAppHost
Inherits AppHostBase
Public Sub New()
MyBase.New("Web Services", GetType(BiffaNetWebService).Assembly)
End Sub
Public Overrides Sub Configure(ByVal container As Container)
Routes.Add(Of APIRequest)("/api").Add(Of APIRequest)("/api/{ActionName}")
End Sub
End Class
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Dim apphost = New HelloAppHost()
apphost.Init()
End Sub
End Class
WS.vb
Public Class WebService
Implements IService(Of APIRequest)
Public Function Execute(ByVal request As APIRequest) As Object Implements ServiceStack.ServiceHost.IService(Of APIRequest).Execute
Dim ActionName = request.ActionName
Dim UserData = request.UserData
// Do some stuff here and return JSON
End Function
End Class