且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

默认动态+静态路由在asp.net MVC 5

更新时间:2023-02-16 16:47:53

尝试设置你的路线如下(我在VB写我的,但你应该能够很容易地翻译):

Try setting your route as follows (I am writing mine in VB, but you should be able to translate easily):

routes.MapRoute(
        name:="Customers",
        url:="Customers/{*pathInfo}",
        defaults:=New With {.controller = "Customers", .action = "Login"}
    )

要访问它,只需访问:

http://yoursite.com/Customers/John/JohnsHomePage

然后,您的客户控制器将有一个登录方法,像这样:

Then, your Customers Controller would have a Login method like so:

Function Login(ByVal pathInfo As String) As ActionResult
    ' Use your path info to extract your information
    ' It will only contain the part of the URL past the /Customers path
    ' Parse pathInfo to get returnUrl

    ' Do your page work
    Response.Redirect(returnUrl)
End Function

更改客户URL路径登录或别的东西。

Change the Customers url path to Login or something else.