Hi folks,
i wish to have the following url(s).. and i'm not sure how i should do the following:
1) Route registered in the global.asax
2) Controller method
Urls/Routes
- http://www.mysite.com/
- http://www.mysite.com/?page=2
- http://www.mysite.com/?tags=fooBar
- http://www.mysite.com/?page=2&tags=fooBar
Please note - i do not want to have http://www.mysite.com/{page}/{tags}/
etc.. if that difference makes sence. I also understand about the default routes, but i'm not sure how to tweak them to make it do what i require.
Lastly, i also know how to use Html.ActionLink(..) so I'm not worried about how to use that.
any suggestions?
Unit Testing
I'm also under the impression that i could do a unit test, like the following:- (using MvcFakes)...
// Arrange.
var routes = new RouteCollection();
MvcApplication.RegisterRoutes(routes);
// Act.
context = new FakeHttpContext("~/?page=2&tags=fooBar");
routeData = routes.GetRouteData(context);
// Assert.
Assert.AreEqual("Home", routeData.Values["controller"]);
Assert.AreEqual("Index", routeData.Values["action"]);
Assert.AreEqual(2, routeData.Values["page"]);
Assert.AreEqual("fooBar", routeData.Values["tags"]);
Update 1
I'm hoping to run all these of the Index action on the default HomeController, if this helps. (in actual fact, I've renamed my HomeController to PostController but that is not really important / shouldn't effect the problem).