Asp.Net MVC Tutorials About Folder Structure

                       
Asp.Net MVC Tutorials About Folder Structure


Asp.Net MVC Folder Structure
Asp.Net MVC Folder Structure


Asp.Net MVC Folder Structure creates by Visual Studio. Check  " How to create the Asp.Net MVC Application". in this structure you can find the Models, Views, Controllers, App_Start, App_Data, Scripts, Content, Fonts, Properties, References, Web.Config, Global.asax files. each folder has its own significance. let's see the importance of each folder.

Asp.net MVC Controllers


   Controllers handle the user request from the browser and return the response back to the user as per the incoming URL request. The controller is a class derived from the abstract class controller. The controller contains the public action method. it must be derived from the System.Web.MVC.Controller Class.

Asp.net MVC Models


Asp.net MVC Model contains all application Logic that is Business Logic, Validation Logic, Data Access Logic. it holds the data in the form of Public properties. the model class placed inside Model Folder in the Structure.


 Model Class Looks below example.
        
                   namespace alltechgeeks.Models
                     {
                            public class EMP
                             {
                                 public int id { get; set; }
                                 public  string name   {  get;  set;  }
                                 public  string City     {  get;  set;  }

                             }
                      }


Asp.Net MVC Views

the views are store in view folders. every controller has one folder in the view folder with the same name as the controller name. how many action methods are available in the controller that many views are available in the views folder with an extension of   ".cshtml". (Razor View Engine)
 The main advantage of views is to display the data from the model to view.
The shared folder in views are used to share the views, partial views and layouts are shared among multiple views.

 App_Data

  This folder contains Database related files like .mdf file, Local DB, XML files, and other database-related files. these files are not accessed directly in the browser so these files are secured.

 App_Start

 this folder contains some configuration class files. this file plays the main role while executing the application. we can find the config class files below

  1.    RouteConfig.cs
  2.    FilterConfig.cs
  3.    BundleConfig.cs
  4.    AuthConfig.cs
Each config file has its own properties.

Content

 This folder contains the .css files, these files are static files. And here we can place the images, icons, etc. from version MVC 5 onwards, you can find default bootstrap.css and also bootstrap.min.css.

Scripts

this folder contains the all javascript files like bootstrap.js, bootstrap.min.js, jquery.js and jquery.min.js files, etc.

Global.asax

Global.asax contains the code that is executed in response to the session and application-level events such as Application_Start, Session_Start, Application_Error, Session_End, Application_End, and Application_Disposed.

Web.config

it contains the application-level configuration. if you want to access through the application, in that scenario you should go web.config file and declare in XML format.


Previous Post Next Post