How do I get this ASP.NET routing to work properly? -
i'm trying write simple prototype of cms system using asp.net mvc 3.
the system has single controller 2 actions: show , create.
the format 'show' action meant take 5 optional parts, e.g. domain.com/part1/part2/part3/part4/part5
the format 'show' action similar, should have leading 'create' part e.g. domain.com/create/part1/part2/part3/part4/part5
i have following settings in global.asax:
routes.maproute( "createpageroute", "create/{part1}/{part2}/{part3}/{part4}/{part5}", new { controller = "page", action = "create", part1 = urlparameter.optional, part2 = urlparameter.optional, part3 = urlparameter.optional, part4 = urlparameter.optional, part5 = urlparameter.optional }); routes.maproute( "default", "{part1}/{part2}/{part3}/{part4}/{part5}", new { controller = "page", action = "show", part1 = urlparameter.optional, part2 = urlparameter.optional, part3 = urlparameter.optional, part4 = urlparameter.optional, part5 = urlparameter.optional } );
if 'show' method fails find page matching supplied path, returns 'not found' page includes options create new page supplied path. link defined using following:
@html.actionlink("yes", "create")
[the "yes" represents answer question "do want create page path?"]
so when testing 'default' route, see 'show' action called of following paths: {empty} a/b a/b/c a/b/c/d a/b/c/d/e
which great.
however, resulting 'create' link generated statement "@html.actionlink("yes", "create")" gives inconsistent results. seems generate different hyperlink depending on length of input. results follow:
for path "{empty}", link offers "localhost{:port}/" - hoping "localhost{:port}/create"
for path "/a", link offers "localhost{:port}/" - hoping "localhost{:port}/create/a"
for path "/a/b", link offers "localhost{:port}/a" - hoping "localhost{:port}/create/a/b"
for path "/a/b/c", link offers "localhost{:port}/a/b" - hoping "localhost{:port}/create/a/b/c"
for path "/a/b/c/d", link offers "localhost{:port}/create/a/b/c/d" - hoping for
for path "/a/b/c/d/e", link offers "localhost{:port}/create/a/b/c/d/e" - hoping for
why work when supply "/a/b/c/d" or "/a/b/c/d/e"?
i know i'm being idiotic, please me
sandy
i believe multiple optional parameters causing discrepency.
how about:
routes.maproute("create5", "create/{part1}/{part2}/{part3}/{part4}/{part5}", new { controller = "page", action = "create", part5 = urlparameter.optional }); routes.maproute("create3", "create/{part1}/{part2}/{part3}", new { controller = "page", action = "create", part3 = urlparameter.optional }); routes.maproute("create1", "create/{part1}", new { controller = "page", action = "create", part1 = urlparameter.optional }); routes.maproute("default5", "{part1}/{part2}/{part3}/{part4}/{part5}", new { controller = "page", action = "show", part5 = urlparameter.optional }); routes.maproute("default3", "{part1}/{part2}/{part3}", new { controller = "page", action = "show", part3 = urlparameter.optional }); routes.maproute("default1", "{part1}", new { controller = "page", action = "show", part1 = urlparameter.optional });
Thanks for give us valuable information If you are Looking for D-link Support , visit on
ReplyDeleteD-link router reset
dlink router
D-link Support