简体   繁体   English

忽略vb.net中的路由?

[英]Ignore routes in vb.net?

I need help with converting this to vb.net... 我需要将其转换为vb.net的帮助...

routes.IgnoreRoute("{*allaspx}", new {allaspx=@".*\.aspx(/.*)?"});
routes.IgnoreRoute("{*robotstxt}", new {robotstxt=@"(.*/)?robots.txt(/.*)?"});

Any idea? 任何想法?

How about this? 这个怎么样?

routes.IgnoreRoute("{*allaspx}", New With {.allaspx = ".*\.aspx(/.*)?"})
routes.IgnoreRoute("{*robotstxt}", New With {.robotstxt = "(.*/)?robots.txt(/.*)?"})

you need to import System.Web.Mvc 您需要导入System.Web.Mvc

this is what I used in a VB.NET ASP.net Web-Forms app (with mvc5) 这就是我在VB.NET ASP.net Web窗体应用程序(带有mvc5)中使用的内容

Imports System.Web.Mvc

Public Module RouteConfig
    Public Sub RegisterRoutes(ByVal routes As RouteCollection)
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}")

        ' keep default.aspx for empty url
        routes.IgnoreRoute("")

        routes.MapRoute(
            name:="Default",
            url:="{controller}/{action}/{id}",
            defaults:=New With {.controller = "Home", .action = "Index", .id = UrlParameter.Optional}
        )
    End Sub
End Module

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM