asp.net mvc - asp .net mvc routing url with custom literal -


is possible make url custom literal separator can have default parameters ?

context.maproute(             "forums_links",             "forum/{forumid}-{name}",             new { area = "forums", action = "index", controller = "forum" },             new[] { "jami.web.areas.forums.controllers" }         ); 

i have see im using dash separate id name can have url like:

/forum/1-forum-name 

instead of:

/forum/1/forum-name 

i see problem i'm using multiple dashes. , routing engine don't know 1 separate. overalll doesn't change question because want use multiple dashes anyway.

very interesting question.

the way come daniel's, 1 feature.

context.maproute(     "forums_links",     "forum/{forumidandname}",     new { area = "forums", action = "index", controller = "forum" },     new { item = @"^\d+-(([a-za-z0-9]+)-)*([a-za-z0-9]+)$" } //constraint     new[] { "jami.web.areas.forums.controllers" } ); 

that way, items matched route ones formatted in pattern of:

[one or more digit]-[zero or more repeating groups of string separated dashes]-[final string] 

from here use method daniel posted parse data need forumidandname parameter.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -