Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net Visual Basic中的ASP.NET MVC2小写路由_Vb.net_Asp.net Mvc 2_Routing_Routes - Fatal编程技术网

Vb.net Visual Basic中的ASP.NET MVC2小写路由

Vb.net Visual Basic中的ASP.NET MVC2小写路由,vb.net,asp.net-mvc-2,routing,routes,Vb.net,Asp.net Mvc 2,Routing,Routes,我在C#中找到了4到5个“小写路由”的例子,但是当我使用telerik代码转换器时,我得到了一大堆错误 也就是说,与有关的内容“扩展方法只能在模块中定义。” 有没有人有关于如何在VB中将路由映射为小写的好资源 编辑: 下面是一些发生错误的转换代码的示例 Imports System Imports System.Web.Mvc Imports System.Web.Routing Namespace MyMvcApplication.App.Helpers Public Class L

我在C#中找到了4到5个“小写路由”的例子,但是当我使用telerik代码转换器时,我得到了一大堆错误

也就是说,与
有关的内容“扩展方法只能在模块中定义。”

有没有人有关于如何在VB中将路由映射为小写的好资源

编辑: 下面是一些发生错误的转换代码的示例

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
导入系统
导入System.Web.Mvc
导入System.Web.Routing
命名空间mymvcapapplication.App.Helpers
公共类小写字符
继承System.Web.Routing.Route
Public Sub New(ByVal url作为字符串,ByVal routeHandler作为iroutHandler)
MyBase.New(url、routeHandler)
端接头
Public Sub New(ByVal url作为字符串,ByVal默认为RouteValueDictionary,ByVal routeHandler作为IRoutHandler)
新建(url、默认值、routeHandler)
端接头
Public Sub New(ByVal url为字符串,ByVal默认为RouteValueDictionary,ByVal约束为RouteValueDictionary,ByVal routeHandler为IRoutHandler)
新建(url、默认值、约束、routeHandler)
端接头
Public Sub-New(ByVal url作为字符串,ByVal默认为RouteValueDictionary,ByVal约束作为RouteValueDictionary,ByVal数据令牌作为RouteValueDictionary,ByVal routeHandler作为IRoutHandler)
新建(url、默认值、约束、数据令牌、routeHandler)
端接头
公共重写函数GetVirtualPath(ByVal requestContext作为requestContext,ByVal值作为RouteValueDictionary)作为VirtualPath数据
作为VirtualPathData=MyBase.GetVirtualPath的Dim路径(请求上下文,值)
如果路径不是空的,那么
path.VirtualPath=path.VirtualPath.ToLowerInvariant()
如果结束
返回路径
端函数
末级
公共不可继承类RouteCollectionExtensions
私人分新
端接头
_
公共共享子映射RouteLowerCase(ByVal路由为RouteCollection,ByVal名称为String,ByVal url为String,ByVal默认为Object)
routes.MapRouteLowercase(名称、url、默认值、无)
端接头
_
公共共享子映射RouteLowerCase(ByVal路由为RouteCollection,ByVal名称为String,ByVal url为String,ByVal默认值为Object,ByVal约束为Object)
如果路线不算什么的话
抛出新的ArgumentNullException(“路由”)
如果结束
如果url什么都不是,那么
抛出新的ArgumentNullException(“url”)
如果结束
Dim route=New LowercaseRoute(url,New MvcRouteHandler())和{_
.Defaults=新的RouteValueDictionary(默认值)_
.Constraints=新RouteValueDictionary(约束)_
}
如果[String].IsNullOrEmpty(名称),则
路线。添加(路线)
其他的
路由。添加(名称、路由)
如果结束
端接头
末级
结束命名空间
解决“扩展方法只能在模块中定义”的问题: 将定义这些方法的“NotInheritable class”更改为“Module”,并删除构造函数。

以解决“只能在模块中定义扩展方法”的问题。问题:
将定义这些方法的“NotInheritable类”更改为“Module”,并删除构造函数。

Dumb me。。。已经很晚了。。。我试着换潜艇,而不是换班。谢谢你的帮助,让我哑口无言。。。已经很晚了。。。我试着换潜艇,而不是换班。谢谢你的帮助。