Saturday, October 27, 2018

Asp.Net MVC 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. lets see the importance of each folder. MVC Controllers

   Controllers handles the user request from the browser and returns  the response back to the user as per incoming URL request. Controller is a class derived from abstract class controller. Controller contains the public action method. it must be derived from the System.Web.Mvc.Controller Class. MVC Models MVC Model contains the all application Logic that are Business Logic, Validation Logic, Data Access Logic. it holds the data in the form Public properties. the model class placed inside Model Folder in the Structure.

 Model Class Look 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 views folders. every controller has  one folder in views folder with same name of controller name. how many action methods are available in controller that many views are available in views folder with extension of   ".cshtml". (Razor View Engine)
 The main advantage of views are to display the data from model to view.
Shared folder in views are used to share the views, partial views and layouts  are shared among multiple views.


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


 this folder contains the  some configuration class files. this files plays a mainbrole while executing the application. we can find the config class files like below

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


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


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


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


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

No comments: