January 29, 2015 05:57 by Mark
Today i will explains about how to use areas in ASP.NET MVC. When we create a new MVC project then Model, View and Controller folders are created automatically.
This structure is common for simple applications, but when your application grows and becomes complex then the single Model, View and Controller can become complicated. So we can maintain a complex MVC application using areas. Using areas, we can write more maintainable code for an application cleanly separated by the modules.
Step by Step
- So first create a new MVC empty project.
- Then right-click on Solution Explorer and click on add and select area.
- Now add a second Employee area. In your Solution Explorer show your Model, View and Controller in a different student and employee area.
- Now add a Home Controller and in the Index action add an Index View for both the student and employee area.
- Now run the project. (Ctrl+F5).
- For the Teacher area the follwing is the URL localhost/Teachers/Home/Index.
- Here Teachers is the area name, Home is the controller and Index is the Action name.
- For the Teacher area the follwing is the URL localhost/Students/Home/Index.
- Here Students is the area name, Home is the controller and Index is the Action name.
TOP No#1 Recommended ASP.NET MVC Hosting
ASPHostPortal.com is the leading provider of Windows hosting and affordable ASP.NET MVC Hosting. ASPHostPortal proudly working to help grow the backbone of the Internet, the millions of individuals, families, micro-businesses, small business, and fledgling online businesses. ASPHostPortal has ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch, ASPHostPortal guarantees the highest quality product, top security, and unshakeable reliability, carefully chose high-quality servers, networking, and infrastructure equipment to ensure the utmost reliability.