url - MVC Advanced Routing -
I am trying to route the URL that does not have a constant action, which users can create systems Which is any string I have to have URL like the following:
http://yousite.com/System/WIN1234/Configure
By default the routing mechanism thinks that WIN1234 is the action, while I want to be able to catch WIN1234 and throw a system to decide. As:
Public Zero Root System System (word string, string action) {Switch (verb) {case "Configure": Configure System (String System); break; }}
How can I do this? Is it logical or am I thinking all about it wrong?
What you need to do is possible. You have to set a default route that indicates system action, and you have to accept other values as the parameters of action.
// Common routes MapRoute ("Default7", // root with name "{action} / {param1} / {param2}", // parameters new {controller = "home", action = "index", param1 = "", param2 = ""} // parameter defaults);
In your code you will get Win1234 value and will be configured as default.
Then you can apply your switching logic and use RedirectToAction to act as you wish.
Comments
Post a Comment