MVC Developer Question:

Tell us attribute based routing in MVC?

Tweet Share WhatsApp

Answer:

In ASP.NET MVC 5.0 we have a new attribute route, By using the "Route" attribute we can define the URL structure. For example in the below code we have decorated the "GotoAbout" action with the route attribute. The route attribute says that the "GotoAbout" can be invoked using the URL structure "Users/about".

☰ public class HomeController: Controller
☰ {
☰ [Route("Users/about")]
☰ publicActionResultGotoAbout()
☰ {
☰ return View();
☰ }
☰ }

Download MVC Developer PDF Read All 50 MVC Developer Questions
Previous QuestionNext Question
Explain what are Filters in MVC?Suppose if we have multiple filters, what’s the sequence for execution?