Harikrishnan Rajandiran
What is attribute routing in ASP.NET MVC?
By Harikrishnan Rajandiran in .NET on May 07 2018
  • nilesh makadiya
    Jul, 2018 19

    Routing is how ASP.NET MVC matches a URI to an action. MVC 5 supports a new type of routing, called attribute routing. As the name implies, attribute routing uses attributes to define routes. Attribute routing gives you more control over the URIs in your web application.Why Attribute Routing?For example, a socially enhanced e-commerce website could have the following routes:{productId:int}/{productTitle}Mapped to ProductsController.Show(int id){username}Mapped to ProfilesController.Show(string username){username}/catalogs/{catalogId:int}/{catalogTitle}Mapped to CatalogsController.Show(string username, int catalogId)

    • 2
  • Mayank
    Sep, 2018 6

    If we want to give route information on the top of action in controller then it is called attribute routing. [Route("customers/orders")] public IEnumerable GetCustomers() { ... }By this routing route config looks clean. Any change on a route for action do not effect other routes.

    • 1
  • Bidyasagar Mishra
    Jul, 2019 8

    Routing means how a mvc appilication matches to the action .
    For the costumize URI we should use attribute routing.
    For create attribute routing we will set it into App_Start->; WebApiconfig.cs.
    Then we will set a URI above the action .

    • 0
  • Madan Shekar
    Oct, 2018 18

    go through this linkhttps://blogs.msdn.microsoft.com/webdev/2013/10/17/attribute-routing-in-asp-net-mvc-5/

    • 0
  • Rushyanth Reddy
    Aug, 2018 5

    Routing is how a MVC application matches a URI to an Action. Attribute Routing uses attributes to define routesFor ex:[Route(“books/lang/{lang=en}”)]public ActionResult ViewByLanguage(string lang){return View(“OneBook”, GetBooksByLanguage(lang));}

    • 0
  • Harikrishnan Rajandiran
    May, 2018 7

    ''

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS