asp.net mvc 2 - How can we Route something like {calendar}/{controller}/{action}/{id} -


as beginner in mvc i'm trying figure out what's best way accomplish route needs, , i'm getting no luck @ all, i'm kindly ask help

my webapp driven calendars, , per each calendar there bunch of actions

  • subscribe
  • edit calendar
  • view winners
  • daily challenge
  • etc...

and avoid passing like

mydomain.com/calendar/2 

my idea hide id no 1 can have logical access other calendars, example

mydomain.com/q2tst 

where q2tst 10 char random generated string , i have routes such as:

mydomain.com/q2tst/subscribe mydomain.com/q2tst/daily-challenge mydomain.com/q2tst/winners mydomain.com/q2tst/prizes 

how set route perform this?

something like:

routes.maproute(     "calendarroute",     "{calendar}/{controller}/{action}/{id}",     new {          calendar = "empty",          controller = "frontend",          action = "index",          id = urlparameter.optional } ); 

but calendar? pick up can convert id querying db faster

i'm kinda lost here :(

firstly, 'hiding' calendar id behind string there still nothing stop user trying guess appropriate id. whatever solution use need have security built in actions ensure appropriate data shown authorized users.

to calendar - pass string value action method , decode there.

routes.maproute(     "calendarroute",     "{calendar}/{controller}/{action}/{id}",     new {          calendar = "empty",          controller = "frontend",          action = "index",          id = urlparameter.optional } );  public actionresult index(string calendar, int? id) {    // decode calendar useful ...     } 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -