c# - How can I configure the following route? - Imply action method from URL pattern -


I have a program controller , which has several action methods for the version, such as EditDetails , EditContacts , EditRules (plus 10 but I'll take them out for simplicity). Currently the URL for this action methods looks something like the following:

  http: // localhost / program / 1 / editcontents contact http: // localhost / program / 1 / editdetails http  1 / contacts / edit Http: // localhost / program / 1 / details / edit http: // localhost / program / 1 / rules / edit  

which makes me more understandable.

So far this is my my register rosts method:

  public static zero register routes {routes.gnoreRoute ("{ Resource} .axd / {* pathInfo} "); Routes.MapRoute (name: "ProgramInfo", url: "program / {id} / {action}", default: new {controller = "program"}); Routes.MapRoute (name: "ProgramDefault", url: "program / {action}", default: new {controller = "program", action = "index"}); Routes.MapRoute (name: "default", url: "{controller} / {action} / {id}", default: new {controller = "home", action = "index", id = urlparameter.option}}; }  

I have found so far to obtain that there is a path for each verb method, such as the following:

  routes.MapRoute (name : "Edit communication", url: "program / {id} / contact / edit", default: new {controller = "program", verb = "edit contact"});  

But I'm trying to find a better solution to avoid repetition. Some have passed my mind like the following but it incorrect :

  routes. MapRoute (name: "editing program", url: "program / {id} / {variable} / edit", default: new {controller = "program", action = "edit" + "{variable}"}) ;  

Thank you in advance for your help.

You want to push your contacts in the contact controller, details in the details controller etc. It fits naturally to how you are describing your URL space.

If you want indirection on a second level then you can use the field.

Note: You can apply your own root-handler or your own root based on the rootbank, but it looks like a really big hammer for your question.

Here is a link to such an approach:


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -