tri_inn

tri_inn

  • NA
  • 1.2k
  • 234k

When to use Area attribute along with controller

Apr 20 2017 9:28 AM
see the below code and tell me when some one use Area attribute along with controller.

is it any kind of attribute routing for which area attribute keyword is used along with controller ?

does it mean only user with admin role can access home controller ?

[Area("Admin")]
public class HomeController : Controller
{
// GET: /<controller>/
public IActionResult Index()
{
return View();
}

public IActionResult Details()
{
return View();
}
}

i got the above code from this url http://www.dotnetfunda.com/articles/show/3390/using-area-in-aspnet-core
so if i understand correctly then it means Area attribute allow to change the url? am i right ?

when we create area folder in project then it would mandatory to use area attribute on controller or action method ?

see these url which talking about area

https://www.codeproject.com/Articles/714356/Areas-in-ASP-NET-MVC

http://www.dotnettricks.com/learn/mvc/mvc-areas-with-example

the above url show how to work with area but they never use [Area("Admin")] in code.

so still it is not clear when to use [Area("Admin")] in code.

please make this area more clear for me. thanks

 
 
 

Answers (3)