Note that there are some explanatory texts on larger screens.

plurals
  1. POHow should i make this ASP.NET MVC Route?
    primarykey
    data
    text
    <p>i wish to have the following url(s).. and i'm not sure how i should do the following:</p> <p>1) Route registered in the global.asax<br> 2) Controller method</p> <h2>Urls/Routes</h2> <pre><code>- http://www.mysite.com/ - http://www.mysite.com/?page=2 - http://www.mysite.com/?tags=fooBar - http://www.mysite.com/?page=2&amp;tags=fooBar </code></pre> <p>Please note - i do not want to have <code>http://www.mysite.com/{page}/{tags}/</code> 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.</p> <p>Lastly, i also know how to use Html.ActionLink(..) so I'm not worried about how to use that.</p> <p>any suggestions?</p> <h2>Unit Testing</h2> <p>I'm also under the impression that i could do a unit test, like the following:- (using MvcFakes)... </p> <pre><code>// Arrange. var routes = new RouteCollection(); MvcApplication.RegisterRoutes(routes); // Act. context = new FakeHttpContext("~/?page=2&amp;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"]); </code></pre> <h2>Update 1</h2> <p>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).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload