Tutorial by Examples

Custom routing provides specialized need of routing to handle specific incoming requests. In order to defining custom routes, keep in mind that the order of routes that you add to the route table is important. public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute(&qu...
User can add custom route, mapping an URL to a specific action in a controller. This is used for search engine optimization purpose and make URLs readable. routes.MapRoute( name: "AboutUsAspx", // Route name url: "AboutUs.aspx", // URL with parameters defaults: new { c...
Along with classic way of route definition MVC WEB API 2 and then MVC 5 frameworks introduced Attribute routing: public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); // This...
When you request the url yourSite/Home/Index through a browser, the routing module will direct the request to the Index action method of HomeController class. How does it know to send the request to this specific class's specific method ? there comes the RouteTable. Every application has a route ta...
Suppose we want to have a route that allows an unbound number of segments like so: http://example.com/Products/ (view all products) http://example.com/Products/IT http://example.com/Products/IT/Laptops http://example.com/Products/IT/Laptops/Ultrabook http://example.com/Products/IT/Laptops/Ult...
It's a good practice to encode state of Single Page Application (SPA) in url: my-app.com/admin-spa/users/edit/id123 This allows to save and share application state. When user puts url into browser's address bar and hits enter server must ignore client-side part of the requested url. If you serv...
For using Attribute Routing in areas, registering areas and [RouteArea(...)] definitions are required. In RouteConfig.cs : public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); ...

Page 1 of 1