Я новичок в маршрутизации URL.
Случай 1: я могу реализовать маршрутизацию URL для URL:/content/category.aspx
, сопоставленной с /Reservation
Случай 2. Я не совсем уверен, как обрабатывать значения строки запроса.
Например:
URL:/content/category.aspx?SID=5&CID=191
Я хочу, чтобы это отображалось на: /Reservation
Код, написанный для дела 1:
Global.asa
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
RegisterRoutes(RouteTable.Routes)
End Sub
Shared Sub RegisterRoutes(ByVal routes As RouteCollection)
Dim urlPattern As String
Dim Reservation As Route
urlPattern = "Reservation/"
Reservation = New Route(urlPattern, New JRouteHandler("~/content/category.aspx"))
RouteTable.Routes.Add("Reservation", New Route("Reservation", New JRouteHandler ("~/content/category.aspx")))
End Sub
Http Handler
Public Sub New(ByVal virtualPath As String)
_virtualPath = virtualPath
End Sub
Public Function GetHttpHandler(ByVal requestContext As RequestContext) As IHttpHandler Implements IRouteHandler.GetHttpHandler
If (Not UrlAuthorizationModule.CheckUrlAccessForPrincipal(_virtualPath, requestContext.HttpContext.User, requestContext.HttpContext.Request.HttpMethod)) Then
requestContext.HttpContext.Response.StatusCode = CInt(Fix(HttpStatusCode.Unauthorized))
requestContext.HttpContext.Response.End()
End If
Dim display = TryCast(BuildManager.CreateInstanceFromVirtualPath(_virtualPath, GetType(Page)), name)
display.pageName = TryCast(requestContext.RouteData.Values("name"), String)
Return display
End Function
Public Interface name
Inherits IHttpHandler
Property pageName() As String
End Interface
-В веб-конфигурации
</modules>