Areas in ASP.NET MVC 5

Area Example :https://drive.google.com/file/d/1eZZdAbMT_x2HOVMMpU2yvvfv-V_5EahD/view?usp=sharing
What is Area in ASP.NET MVC?
Area allows us to partition/divide the large application into smaller units where each unit contains a separate MVC folder structure, same as the default MVC folder structure. You can divide the aplication into areas as per use case, or sub module or module or functional unit depending on your requirements.
The large ASP.NET MVC application includes many controllers, views, and model classes. So it can be difficult to maintain it with the default ASP.NET MVC project structure.
Here we can use ASP.NET MVC feature called Area so that we can divide large application into different different areas. For example, a large enterprise application may have different modules like admin, billing, support, marketing, etc. So an Area can contain a separate MVC folder structure for all these modules, as shown below.

As you can see, each area includes the AreaRegistration class. The following is adminAreaRegistration class created with admin area.
public class adminAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "admin";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"admin_default",
"admin/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
}
}
The AreaRegistration class overrides the RegisterArea method to map the routes for the area. In the above example, any URL that starts with the admin will be handled by the controllers included in the admin folder structure under the Area folder. For example, http://localhost/admin/profile will be handled by the profile controller included in the Areas/admin/controller/AdminHomeController folder.
Layouts in Area: –
Every area can have it’s own layout and _Viewstart file so that the views from that area can use that layout.
If any view uses layout from area and if area do not have layout it will automatically copy the default area in shared folder of that area.
Action Links in Areas:
When you use the action links in area you should be care full about the area name, because in previous paragraph we learnt that if you want to invoke any action from the area using action link then we need to use area name as first string in request url so when you use the action link to divert to the controllers from area you need to pass the area name in route values parameter in action link.
Route Values parameter in Action Link: –
Actin link helper has route values parameter and it will help you to add some parameter in request url syntax for the same is as follows –
@Html.ActionLink("text","actioname",routervaluesparameter)
@Html.ActionLink("text","actionname","controllername",routevaluesparameter,htmlattribute)
When you define a parameters in route values parameter it will check weather it is built in parameter, if it is a built in parameter then it will append it’s value at appropriate location in request url , if it is not built in parameter it will append it as query string parameter in request url.
e.g.
@Html.ActionLink("go to index","Index","Home", new {id=10,a="Ganesh"})
This will create a the url http://localhost:89898/home/index/10/?a=Ganesh here id is built in parameter so it get append at it’s position and but a is not built in parameter so it get append as query string parameter.
Similar way we can pass the area name as a route parameter in action link.
@Html.ActionLink("Go to Admin Home","Index","AdminHome",new {id="Sunil",area="Admin",val=10},null}
It will generate the following url –
http://localhost:89898/admin/adminhome/Index/Sunil/?val=10
Since area and id is built in variables so those get appended at their appropriate location and val will be get appended as the query string parameter.
michelle benecke washington dc
September 14, 2023 at 7:14 amMichelle Benecke- Harvard Law
340 Dirksen Senate Office Building
Washington D.C, 20510
202-224-2627
michelle benecke washington dc
What is Melaleuca
September 15, 2023 at 12:34 pmUniversity of Florida/IFAS
Center for Aquatic and Invasive Plants
7922 NW 71 Street
Gainesville, Florida 32653
352-392-9613
What is Melaleuca
Bogarts Café MenuBogarts Café
October 3, 2023 at 7:29 pmBogarts Café
3045 Monsarrat Ave
Honolulu, HI 96815
(808) 739-0999
Bogarts Café MenuBogarts Café
michelle benecke
October 11, 2023 at 9:38 amMichelle Benecke- Harvard Law
340 Dirksen Senate Office Building
Washington D.C, 20510
202-224-2627
michelle benecke
Where is Herbert Hernandez from
October 14, 2023 at 7:14 amLink exchange Where is Herbert Hernandez from nothing else however it is only placing the
other person’s website link on your page at appropriate place and other person will also
do same for you.
electric bikes in miami
October 22, 2023 at 6:26 amSea Dream Inc.
1599 Superior Ave A4
Costa Mesa CA 92627
949-515-0055
electric bikes in miami
7k Metals reviews
October 27, 2023 at 8:28 pm7k Metals
3640 S Yellowstone Hwy
Idaho Falls, ID 83402
208-314-2587
7k Metals reviews
Memphis vacation rental management
November 1, 2023 at 3:45 pmAdvantage Property Management
399 Distribution Parkway,
Collierville, TN 38017
(901) 347-3148
Memphis vacation rental management
Divorce Lawyer
November 5, 2023 at 10:58 pmTAYLOR MCCORD PRAVER CHERRY
255 MAPLE CT STE 120
VENTURA, CA 93003-9136
(805) 410-8119
Divorce Lawyer
electric bikes in costa mesa
November 10, 2023 at 11:07 pmSea Dream Inc.
1599 Superior Ave A4
Costa Mesa CA 92627
949-515-0055
electric bikes in costa mesa
SER verified lists trial
November 13, 2023 at 10:14 pmI like tto tick waiut at least 15 minutes between two
ligins and you can leave the rest oof them at default.
Here is my web-site :: SER verified lists trial
metal supermarkets in los angeles
November 24, 2023 at 8:20 amMetal Supermarkets Anaheim
1273 N Blue Gum St
Anaheim, CA 92806
(714) 630-2236
metal supermarkets in los angeles