Suresh Kumar
Explain Attribute Routing in ASP.NET MVC5?
By Suresh Kumar in ASP.NET on Nov 06 2017
  • Srikant Maruwada
    Jan, 2018 4

    1. Reduces the chances for errors, if a route is modified incorrectly in RouteConfig.cs then it may affect the entire application's routing.2. decouple controller and action names from route entirely.3. Easy to map two routes pointing to the same action.Attribute Routing is a more flexible solution than Convention Routing, if only because it allows you quite a bit more flexibility and places the routes next to the actions that will actually use them. However there are certainly benefits to using both in tandem, particularly in situations when you know how some routes will look but aren't sure about others.

    • 0
  • Suresh Kumar
    Nov, 2017 6

    we use friendly URLs that are mapped to controller’s actions instead of physical files as in case of ASP.NET WebForms. Now in ASP.NET MVC5, we can use attributes to define routes giving better control over the URIs. We can easily define routes with Controller’s action methods as follows:public class HomeController:controller { [Route("Product/{productId?}")] public ActionResult Product(string prodcutId) { return view() }}

    • 0

Most Popular Job Functions