Using Areas in ASP.NET MVC Application

Introduction

ASP.NET MVC relies on
certain folder and class naming conventions to organize models, views and
controllers. A large application often consists of functionally independent
modules with the result that the main application is essentially a bundle of
these sub-applications. In such cases, organizing various models, views and
controllers can be tedious. Luckily, ASP.NET MVC allows you to split your
application into what is known as Areas. Each area mimics the folder structure
and conventions as required by ASP.NET MVC. This article shows you how Areas
are used in an ASP.NET MVC application.

What are Areas?

Areas are functionally independent modules of your ASP.NET
MVC application that mimic the folder structure and conventions of MVC.
Consider the following scenario :

As you can see the main application has three functionally
independent modules viz. Blog, Help Desk and Shopping. Without any areas in
place, you would have put all the controllers and views in the respective
folder of the main application folder. Obviously, you cannot have the same
controller name for different modules. For example, you cannot have
HomeController for Blog and HomeController for HelpDesk. You either need to put
all action methods of both the modules in a single controller or create two
controllers with altogether different names (say BlogHomeController and
HelpDeskHomeController).

With areas in place, each module replicates the MVC folder
structure. For example, each module will have its own Models, Views and
Controllers folder. You can then have HomeController class in Blog module as
well as HelpDesk module. So, in the above example, essentially you will have
four MVC structures - one for the main application and one each for the three
modules (Blog, HelpDesk and Shopping).

Adding a New Area

Before you work with areas, create a new ASP.NET MVC
application with ASPX view engine. To add a new area right click on the
application in the Solution Explorer and select the Add > Area shortcut menu
option. Doing so will open "Add Area" dialog as shown below:

Figure 2: Adding a New Area

You need to enter the Area Name and click the Add button to
create the folder structure for that area. The following figure shows the
complete folder structure with three Areas - Blog, HelpDesk and Shopping -
added.

Figure 3: Solution Explorer

As you can see, the main application has Areas subfolders.
Inside the Areas subfolders there is a folder for each area you wish to create
(Blog, HelpDesk and Shpping in the above example). Each Areaa subfolder has its
own set of MVC folders (Models, Views and Controllers). You can treat each area
just like the main application and add models, views and controllers in the
respective folders.

Registering Areas with MVC Framework

Simply creating area folder structure is not sufficient, you
also need to inform ASP.NET MVC framework about the areas you've added.
Luckily, this task is automatically done when you add a new area. Notice the
area registration class file that was created under each area folder
(BlogAreaRegistration.cs, HelpDeskAreaRegistration.cs, etc.). The area
registration file contains a class that inherits from AreaRegistration base
class. The HelpDeskAreaRegistration class is shown below :

As you can see the HelpDeskAreaRegistration class overrides
AreaName property and the RegisterArea method. The RegisterArea method
registers the route information for the newly added area with MVC framework.

You will have one area registration class file for each
area. When are the area registration classes used? If you open Global.asax
file, you will have the following code in the Application_Start event handler :

As you can see, there is a call to RegisterAllAreas() static
method of AreaRegistration class. Calling RegisterAllAreas() method in turn
invokes the RegisterArea() method of all the area registration classes found in
the application.

Before going ahead, add HomeController to all the areas and
the main application, i.e. four controller classes with name HomeController.
All the HomeController classes will look like this :

Then right click on each Index() action method and add Index
view, i.e. total four Index views in their respective folders.

Run the application and try navigating to different areas.
The following figure shows a sample run for HelpDesk area. Notice the URL of
the area.

Figure 4: Run the Application

Linking Between Two Areas

ASP.NET MVC Views often need to link to some action method
residing in controller classes. Unless otherwise specified, action methods and
controllers are assumed to be from the current area. In case you wish to link
to an action method belonging to some other area, here is how you would do just
that:

The above fragment is from the Index view of the main area.
It renders four hyperlinks using ActionLink(). Notice the fourth parameter that
specifies area name. This parameter governs the area whose action method is
being linked to.

Redirecting to an Action Belonging to Another Area

You can also redirect to some action method of a specific
area using RedirectToAction() method. Consider the following action method:

As you can see, the Index() action method of the main area
redirects the control to Index() action method of the HelpDesk area.

Summary

ASP.NET MVC allows you to organize your application into
areas. Each area replicates the MVC structure and can be treated as independent
as far as models, views and controllers are concerned. An area is registered
with MVC framework using an area registration class and RegisterAllAreas() call
in the Global.asax file.

About the Author

Bipin Joshi

Bipin Joshi is a blogger and writes about apparently
unrelated topics - Yoga & technology! A former Software Consultant by
profession, Bipin has been programming since 1995 and has been working with the .NET framework ever since its inception. He has authored or co-authored half a dozen books and
numerous articles on .NET technologies. He has also penned a few books on Yoga.
He was a well known technology author, trainer and an active member of Microsoft
developer community before he decided to take a backseat from the mainstream IT
circle and dedicate himself completely to spiritual path. Having embraced Yoga
way of life he now codes for fun and writes on his
blogs. He can also be reached there.

Downloads

Comments

Regarding MVC Folder structure

Posted by Kashif
on 07/12/2015 06:38am

Area
I am finding difficulties to arrange the area folder for my project
This is Job application website and having mainly following type of pages/section
1) - Admin Pages - Only for Admin user(site owners) - so only authenticated(logged in) admin users case see those pages/section
example - Post_Jobs_Page, Edit_Job_Page, Change_Admin_Password, Add_News_Events_Page etc.
2) - Job seeker Pages - only for Job seekers - so only authenticated(logged in) Job Seeker users case see those pages/section
example - change_Password, Edit_Profile, Applied_Jobs etc
3) - Common Pages - where any job seeker either authenticated(logged in) or without authentication can visit those page
Search_Jobs, ContactUs, AboutUs etc
So I am not sure how to organize MVC folder structure - how may areas should i add and where to put which files
Please help
Thanks,
Kashif

Software Developer

å¥³å£«

Posted by savage wames
on 07/20/2013 02:58am

There is no doubt about the fact that vans en ligne help you protect your feet. At the same time, they give you style. When you have a good collection of shoes, you feel quite confident. You have shoes that are used for everyday activities. You might also prefer to wear different footwear or boots for playing some games.Then it is quite possible that you also have some special shoes in collection for special occasions. However, when the collection is not well organized, you may feel lost in front of the footwear. Getting the right footwear from the collection may be quite time consuming. You can make use of some organizing ideas to make the collection useful and aesthetic.
You should start by examining your own acheter vans boutique size. The proportion you need to look out for is simple: for those who have slim ankles, don't select larger shoes for they will certainly come loosened and impair your movements. People with healthy ankles, however, should not purchase a size that fits them too securely for this could cut-off the blood circulation to the foot, evolving into more serious medical problems. Your shoe has to be the right size, neither a size bigger nor a size smaller. Likewise, the toe size of the shoes needs to be exactly correlated to your own. Padding is an additional problem in terms of deciding on the shoes. It is said that the older you are (or the heavier) the greater cushioning in your shoes you would likely need. Good quality and often fairly expensive squash shoes will give you amazing padding, else insoles and particular squash socks are there to help you along. Before choosing anything, you need to explore the size info on the product properly. But the huge assortment of Adidas, Harrow, Asics, Ashaways, Dunlop, karakal, Hi-Tec, Prince and so many more may bamboozle you. We will proceed to go through them now.
There are so many styles of vans femme pas cher you can choose for a night out on the town, so to make the right decision when it comes to style, you have to consider your outfit, what you are going to be doing, and where you plan on wearing the shoes. Not only will this help you choose the best fit, it is also going to allow you to compare a number of fine styles and great shoes, no matter what you eventually choose to wear, or what unique style you want to go out with for the evening. If you are looking for a sexy black or sleek red, or if you want something with various colors, and unique designer prints and styles, when you choose to shop with the top name brand manufacturers for your new shoes, you will find hundreds of fine styles to try out, and you will find a great pair for any occasion and any location you plan on going out to for the evening.
The scientific evidence is quite clear on many of the biomechanical effects of these vans pas cher. They have been shown to increase activity of the muscles and they have been shown to alter the biomechanics of the walk in people using them. While these changes are clear, what the evidence is not clear on is if the outcomes associated with changes that really are only theoretical. For example, there is no doubt that the muscles do tend to work harder when using these shoes, but there is no evidence that this will lead to an increased tone up. There is also no doubt that these shoes do alter the gait, but there is no evidence that this change is either a positive or a negative change. The marketers have taken the laboratory based biomechanical research and speculated a theoretical outcomes change to hype up what these shoes can do. In the extreme cases, there have been claims that they can cure cellulite and improve the circulation. It was this leap that got the companies in trouble with the regulatory authorities.

converse skorarticle

Posted by tvndmiuc
on 06/21/2013 12:15pm

If you would like mens striped glow during the dark socks you'll have to make them on your own with fabric markers or material pens. Now glow within the dark usually signifies they glow underneath black light, or they need to have black light shine on them for you to glow to get a although. So observe what you invest in and study the description. I've also incorporated some neon markers also as glow while in the dark markers considering neon markers will give a glowing effect during the day underneath normal lighting disorders. That is the sole way I could discover up to now so you can have glow inside the dark stripes or neon stripes on your socks.
Trumpette Youngsters GLOW-in-the -Dark Lady SOCKS Maryjane Mary Jane DOT Neon Green Pink Blue 3 prs present Dimension 5-6
Glow while in the Dark Socks
CW-X Unisex Adult Ventilator Compression Help Socks
Thorlo Women's Lite Running Micro-Mini Low-Cut Sock
Thorlo Unisex Thick Cushion Running Rolltop Sock
If you would like make your own personal glow within the dark working socks you will need plain white socks, and a few glow inside the dark paint. You can actually either spritz it on, or you could place it within a spray bottle and spray it on if it doesn't come in a spray can previously. Tulip Material Spray Paint, that is a everlasting fabric paint dries to a terrific colour, is soft and flexible and doesn't fade away or disappear right after repeated washings. Basically spray these glow or neon paints onto your fabric and allow it dry for 24 hours to get a long term, machine-washable shade. Spray freehand, apply to crumpled material for intriguing patterns, or you can use stencils. A different intriguing technique to decorate your socks could be to produce watercolor effects by applying to dampened material. Greatest once you pre-wash your socks initial, and use white or light colored socks. I have integrated some neon paints also as these will demonstrate up through the day light hours and appear to glow.
Thorlo Women's Lite Working Mini Ankle-Cut Sock
Glow in the dark socks for little ones can be a challenge to find but I have collected some good sets to suit your needs to appear at these days. You can go through critiques of any items on this web page by only clicking on any with the hyperlinks. And don't overlook to verify the availability on totally free super conserving shipping.
I have listed some certainly sharp searching neon socks under instead of glow inside the dark socks for men and women alike.
Tulip Material Spray Pack - Neon Colours - Set of 4 Colors
Tulip 29069 Fabric Spray Paint, 9-Pack Assorted Colours
http://www.shenduart.cn/plus/view.php?aid=64180
http://lurrenzinc.com/iftcjsxd/2013/06/15/fashion-icons-childhood-photospun3/

converse skor reanews

Posted by whuzziqf
on 06/16/2013 11:29pm

You will find now two operating playlist possible choices. 1 is Indie rock, Funk, and Jazz and the other is much more intense, face-punching trash, metal, rock using a minor ska. You have got the capability to pick your BPM after you download the songs (ie. 140, 145, 150, 155, 160, 165, 170, 175, 180, 185 BPM). The tempo is constant throughout the song so it is amazing for lengthy runs. It really is unique music played w/ serious instruments, not a standard techno remix track.
Preferred Operating Music for any Marathon
Complete Disclosure: I made these playlists. So certainly I'm listing to start with :) I researched these songs very carefully and just about every song is both exciting, motivational, or precise to working. They may be also two - three hrs lengthy to cover almost all of a marathon. In addition, they start w/ slower BPM then construct to speedier songs since it will get to the end. They may be eclectic mixes of alternative/progressive rock, traditional rock, indie music, some R hop and 80's power-pop. You will discover bands like the Clash, Stones, Gorillaz, the Police, Killers, Kooks, White Stripes, Arctic Monkeys, OutKast, Vampire Weekend, Doors, the Smiths, XTC, etc.
Working to music with as well slow of a tempo could cause you to subconsciously decelerate on the beat. Acquiring the perfect beats per minute (bpm) for your working music can enhance your overall performance. I am not a runner, but I've spent quite a lot of time building running playlists for my wife who has run a number of marathons. In accomplishing so, I grew to become aware of the significance of the bpm of a song and how it relates for your working speed. A lot of us prefer to run to "Eye from the Tiger", but at 109 bpm, it can be way as well slow. Any time you run to music which is also slow, you may subconsciously decelerate to your beat of your song. There have also been several scientific research finished that present that acquiring the "right" music truly improves your perfromance. Another problem with many of the running playlists on the market is the fact that the lyrics are just not motivational. I see working playlists w/ "Blister inside the Sun" or "19th Nervous Breakdown" and though they could have great bpms, it just does not seem to be like everything you want for running music while in the middle of 26.2 miles.
So here are a list of web sites that combine good music, bpm, and motivational songs:
http://www.zshzr.com/bbs/read.php?tid-7014-ds-1.html
http://www.haian.info/home.php?mod=space&uid=16267