Understanding The Folder Structure of ASP.NET MVC Application

Introduction

Day by day ASP.NET MVC becomes the popular framework among the developers because of clean code and folder structure.In this first article of ASP.NET MVC articles series we will understand  folder structure of ASP.NET MVC application.
Many new developer and students are struggling to learn ASP.NET MVC in quick time and in MVC lots of technologies are used like javascript , jQuery , AngularJs , Typescript ,Dapper ,Entity framework and much more because of this developers and students get confused how to start learning ? , by considering above problem and help students and developers who wants to learn quick about MVC, I have decided to start series of articles on ASP.NET MVC .
 MVC And Convention standard
ASP.NET MVC applications, by default, depends  heavily on conventions. This allows developers to
avoid having to configure and specify things that can be inferred based on convention by adding code through Scaffolding .
For instance, MVC uses a convention-based directory-naming structure when resolving View templates and this convention allows you to omit the location path when referencing views from within a Controller class.
MVC is designed around some sensible convention-based defaults that can be overridden as needed.
This concept is commonly referred to as "convention over configuration" which popular concepts of Ruby on Rails programming language.
The convention over configuration concept implemented in ASP.NET MVC with the help of following main directories
  • Controllers
  • Models
  • Views   
Key points 
  • Each controller name ends with suffix controller.
  • The single view directory can be used for entire application.
  • By default all directories (folder) created with name of controller name.
Let's add the ASP.NET MVC application so it will create folder structure under the project solution explorer.
Step 1 : Create MVC Application To Create Folder structure
  1. "Start", then "All Programs" and select "Microsoft Visual Studio 2015".
  2. "File", then "New" and click "Project..." then select "ASP.NET Web Application Template", then provide the Project a name as you wish and click on OK .
The preceding project solution explorer you have seen different folders and files . The preceding folder structure may be different according your MVC project template , So let us learn about major folders in brief as in the following:
  • App_Data
  • App_Start
  • Content
  • Controllers
  • Models
  • views
  • Script
  •  App_Data
This folder is used to store file based database such as sql server .mdf files or xml files etc.like in following image

  • Controller 
 This folder contains the controller and their methods. The controller is responsible for processing the user request and return output.
  •  Models
This folder contains the class files for entities or properties used to store the input values.
 You can rename the folder Model and you can give any name as you wish ,its not mandatory that the folder name should be Models however model name is only for better naming conventions . also Model can be created in separate class library project .

  • View
This folder contains the UI pages including shared page, .CSHTMl, .VBHTML, HTML,aspx pages that show the output to the end user.
  •  Content 
This folder is used to store files related to design and UI such as CSS files ,images which is require for UI..
  • Script
This folder contains the Script files such as JavaScript ,jQuery ,AngularJs ,TypeScript etc.


From preceding example we have learned how the folder structure architectures and use of each folder.
Note:
Its not mandatory that you should use above folder structure and naming conventions, You can rename it and  follow different folder structure as you wish.

To learn more about MVC basic in terms of to understand preceding folder structure practically please refer following videos series.
MVC Basic Videos.
Summary
I hope this article is useful for all readers, if you have a suggestion then please contact me.To learn ASP.NET MVC step by step please refer following articles
For more MVC article ,please refer www.compilemode.com , MVC section using following link.

    Post a Comment

    www.CodeNirvana.in

    Protected by Copyscape
    Copyright © Compilemode