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
Post a Comment