I’m working with ASP.NET MVC but this really applies to any MVC framework. I understand that one of the benefits of an MVC framework is the construction of “pretty” urls. I have kept my small application simple thus far and most routes use the normal convention of: controller/action/id. However, now I’ve created a simple page that will redirect to an action based on the query string parameter given:
mysite.com/visitors/lookup?signAction=signin
or
mysite.com/visitors/lookup?signAction=signout
Coming from Web Forms, this construction is natural and very common, but I’m afraid I’m not realizing the benefits of pretty urls here.
For my example, would it be best to create a custom route or keep it as-is? What is the general rule of thumb for when custom routes end and query string parameters begin?
Honestly, I want to say it depends on your preference, which is the great thing about it. There is no rule of thumb when it comes to making anything. Well, maybe when it comes to performance, but in this case, there is no performance change to worry about. Personally, I’d say create a new route. It’s not too difficult and like you said, it’s pretty URLs. Also, another thing to consider would maybe be a hidden value. I’m not fully sure of your code layout, but if you had a hidden input of signaction and the value changes, then you could just do a Request.Form[“signaction”] to get the value. Hope this helps.