Reputation: 86957
i'm trying to make the following routes .. and currently i'm going about this in a really long way.. ie. one route instance for EACH route.
this is what i'm after... (assuming i'm doing a 'stackoverflow website')
/ <-- root site
/page/{page} <-- root site, but to the page of questions.
/tag/{tag}/page/{page} <-- as above, but the questions are filtered by tag
/question/ask <-- this page :P
/question/{subject} <-- reading about a question
(and no.. i'm most definitely not doing a stackoverflow website :) )
cheers!
(gawd i find dis all so confusing at times).
Upvotes: 0
Views: 298
Reputation: 59001
For your third one, I'd do something like this:
routes.MapRoute("page-tag", "tag/{tag}/page/{page}", new {controller="question", action="FilterByTag"});
Your action method then could look like this:
public class QuestionController : Controller {
public ActionResult FilterByTag(string tag, int page) {
//...
}
}
Upvotes: 2
Reputation: 5730
I would change the last url to /question/view/{subject}. Futher Create 3 controllers:
in Global.asax create those routes,(take example at the default route)
Hope this helps.
Upvotes: 0