I have found 4 or 5 examples of "lowercase routes" in C# however when I use the telerik code converter, I get a bunch of errors.
Namely something to do with "extension methods can be defined only in modules."
Does anyone have any good resources on how to map routes to lowercase in VB?
EDIT:
here is an example of some converted code that is erroring
Imports System
Imports System.Web.Mvc
Imports System.Web.Routing
Namespace MyMvcApplication.App.Helpers
Public Class LowercaseRoute
Inherits System.Web.Routing.Route
Public Sub New(ByVal url As String, ByVal routeHandler As IRouteHandler)
MyBase.New(url, routeHandler)
End Sub
Public Sub New(ByVal url As String, ByVal defaults As RouteValueDictionary, ByVal routeHandler As IRouteHandler)
MyBase.New(url, defaults, routeHandler)
End Sub
Public Sub New(ByVal url As String, ByVal defaults As RouteValueDictionary, ByVal constraints As RouteValueDictionary, ByVal routeHandler As IRouteHandler)
MyBase.New(url, defaults, constraints, routeHandler)
End Sub
Public Sub New(ByVal url As String, ByVal defaults As RouteValueDictionary, ByVal constraints As RouteValueDictionary, ByVal dataTokens As RouteValueDictionary, ByVal routeHandler As IRouteHandler)
MyBase.New(url, defaults, constraints, dataTokens, routeHandler)
End Sub
Public Overrides Function GetVirtualPath(ByVal requestContext As RequestContext, ByVal values As RouteValueDictionary) As VirtualPathData
Dim path As VirtualPathData = MyBase.GetVirtualPath(requestContext, values)
If path IsNot Nothing Then
path.VirtualPath = path.VirtualPath.ToLowerInvariant()
End If
Return path
End Function
End Class
Public NotInheritable Class RouteCollectionExtensions
Private Sub New()
End Sub
<System.Runtime.CompilerServices.Extension()> _
Public Shared Sub MapRouteLowercase(ByVal routes As RouteCollection, ByVal name As String, ByVal url As String, ByVal defaults As Object)
routes.MapRouteLowercase(name, url, defaults, Nothing)
End Sub
<System.Runtime.CompilerServices.Extension()> _
Public Shared Sub MapRouteLowercase(ByVal routes As RouteCollection, ByVal name As String, ByVal url As String, ByVal defaults As Object, ByVal constraints As Object)
If routes Is Nothing Then
Throw New ArgumentNullException("routes")
End If
If url Is Nothing Then
Throw New ArgumentNullException("url")
End If
Dim route = New LowercaseRoute(url, New MvcRouteHandler()) With { _
.Defaults = New RouteValueDictionary(defaults), _
.Constraints = New RouteValueDictionary(constraints) _
}
If [String].IsNullOrEmpty(name) Then
routes.Add(route)
Else
routes.Add(name, route)
End If
End Sub
End Class
End Namespace