ASP.NET Routing in Global.asax

后端 未结 1 536
旧时难觅i
旧时难觅i 2021-01-17 19:04

I\'m trying to add a route in my web forms application by following this:

http://msdn.microsoft.com/en-us/library/cc668201.aspx#adding_routes_to_a_web_forms_applicat

1条回答
  •  北荒
    北荒 (楼主)
    2021-01-17 19:52

    You do not need to specify the name of your website as part of the route, try with this code:

    routes.MapPageRoute("", "{combinedPin}", "~/Default.aspx");
    

    With the above code, your link would look like:

    http://localhost:12345/WebsiteName/test36u
    

    If however your intention is that your users access your site using a segment named: WebsiteName then use:

    routes.MapPageRoute("", "WebsiteName/{combinedPin}", "~/Default.aspx");
    

    But in the precedent code your users will have to access your resource as follows: (probably not the expected result though)

    http://localhost:12345/WebsiteName/WebsiteName/test36u
    

    0 讨论(0)
提交回复
热议问题