Basic concept and fundamentals of ASP.NET MVC (Model View Controller) Architecture

This is basic concepts and fundamentals of ASP.NET Model View Controller (MVC) architecture workflow.


MVC is stands for MODEL VIEW CONTROLLER. ASP.NET MVC is an architecture to develop ASP.NET web applications in a different manner than the traditional ASP.NET web development. Web applications developed with ASP.NET MVC are even more SEO (Search Engine) friendly.
Microsoft .Net Framework 3.5 is minimum requirement to develop ASP.net MVC application.

 

MVC (Model View Controller) Interaction with Browser

Like a normal web server interaction, MVC application also accepts requests and responds to the web browser in the same way.

 Inside MVC Architecture

The entire ASP.NET MVC architecture is based on Microsoft .NET Framework 3.5 and in addition uses LINQ to SQL Server.

What is a Model?

  1. MVC model is basically a C# or VB.NET class
  2. A model is accessible by both controller and view
  3. A model can be used to pass data from Controller to view
  4. A view can use model to display data in page.

What is a View?

  1. View is an ASPX page without having a code behind file
  2. All page specific HTML generation and formatting can be done inside view
  3. One can use Inline code (server tags ) to develop dynamic pages
  4. A request to view (ASPX page) can be made only from a controller’s action method
What is a Controller?
  1. Controller is basically a C# or VB.NET class which inherits system.mvc.controller
  2. Controller is a heart of the entire MVC architecture
  3. Inside Controller’s class action methods can be implemented which are responsible for responding to browser OR calling views.
  4. Controller can access and use model class to pass data to views
  5. Controller uses ViewData to pass any data to view


MVC File Structure & File Naming Standards


MVC uses a standard directory structure and file naming standards which are a very important part of MVC application development.
Inside the ROOT directory of the application, there must be 3 directories each for model, view and Controller.
Apart from 3 directories, there must have a Global.asax file in root folder, and a web.config like a traditional ASP.NET application.
  • Root [directory]
    • Controller [directory]
      • Controller CS files
    • Models [directory]
      • Model CS files
    • Views [directory]
      • View CS files
    • Global.asax
    • Web.config


ASP.NET MVC Execution Life Cycle

Here is how MVC architecture executes the requests to browser and objects interactions with each other.
A step by step process is explained below [Refer to the figure as given below]:

 

Browser Request (Step 1)
Browser request happens with a specific URL. Let’s assume that the user enters URL like: [xyz.com]/home/index/

Job of Global.asax – MVC routing (Step 2)

The specified URL will first get parsed via application_start() method inside Global.asax file. From the requested URL, it will parse the Controller, Action and ID.
So for [xyz.com]/home/index/:
  • Controller = home
  • Action = index()
  • ID = empty — we have not specified ID in [xyz.com]/home/index/, so it will consider as empty string

Controller and Action methods (Step 3)

MVC now finds the home controller class in controller directory. A controller class contains different action methods,
There can be more than one action method, but MVC will only invoke the action method which has been parsed from the URL, its index() in our case.
So something like: homeController.index() will happen inside MVC controller class.
Invoking action method can return plain text string OR rendered HTML by using view.

Call to View (Step 4)

Invoking view will return view(). A call to view will access the particular ASPX page inside the view directory and generate the rendered HTML from the ASPX and will respond back to the browser.
In our case, controller was home and action was index(). So calling view() will return a rendered HTML from the ASPX page located at/views/home/index.aspx.

Comments

Unknown said…
Wonderful post!!Dot net framework use to concentrate on the software environment to give contrast to the hardware environment, this phenomenon is known as the common language runtime. The program written in dot net features like this CLR (common language runtime). This framework works and provides the services like security, memory management, and exception handling.Thank you..!!
Regards,
dot net training in chennai | dot net course
Unknown said…
This comment has been removed by the author.
Unknown said…
Interesting content on the latest arrived technology which is very useful to get updated according to the new trends.
dot net training institute in velachery
Unknown said…
After reading this blog I am very strong in this topics and this blog is really helpful to all.. Explanation are very clear so it is easy to understand.. Thanks for sharing this blog…
Dot Net Training in Chennai | Big Data Analytics Training in Chennai
Unknown said…
Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.


Best Java Training Institute Chennai
Unknown said…
I was curious if you ever considered changing the layout of your site? Its very well written; I love what you’ve got to say. But maybe you could a little more in the way of content so people could connect with it better. You’ve got an awful lot of text for only having one or 2 pictures. Maybe you could space it out better?

Devops Training in Chennai
Unknown said…
This has much useful and interesting guidance for freshers who are looking to upgrade the skills with Dot Net. Thank you.

Dot Net Training in Chennai
Dot Net Course in Chennai
rohil said…
Very interesting blog which helps me to get the in depth knowledge about the technology, Thanks for sharing such a nice blog..
Good discussion.
Six Sigma Training in Abu Dhabi
Six Sigma Training in Dammam
Six Sigma Training in Riyadh
sai said…
Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
python course in pune | python course in chennai | python course in Bangalore
Unknown said…
Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care and we take your comments to heart.As always, we appreciate your confidence and trust in us
Java interview questions and answers

Java training in Chennai | Java training institute in Chennai | Java course in Chennai

Java training in Bangalore | Java training institute in Bangalore | Java course in Bangalore

Java interview questions and answers
Unknown said…

Greetings. I know this is somewhat off-topic, but I was wondering if you knew where I could get a captcha plugin for my comment form? I’m using the same blog platform like yours, and I’m having difficulty finding one? Thanks a lot.

AWS Interview Questions And Answers

AWS Tutorial |Learn Amazon Web Services Tutorials |AWS Tutorial For Beginners


AWS Online Training | Online AWS Certification Course - Gangboard

AWS Training in Toronto| Amazon Web Services Training in Toronto, Canada
Unknown said…
Useful information.I am actual blessed to read this article.thanks for giving us this advantageous information.I acknowledge this post.and I would like bookmark this post.Thanks
Data Science training in rajaji nagar | Data Science Training in Bangalore
Data Science with Python training in chennai
Data Science training in electronic city
Data Science training in USA
Data science training in pune

krishna said…
I really appreciate this post. I’ve been looking all over for this! Thank goodness I found it on Bing. You’ve made my day! Thx again!

angularjs Training in bangalore

angularjs Training in bangalore

angularjs online Training

angularjs Training in marathahalli

angularjs interview questions and answers
dhivya said…
I am really enjoying reading your well written articles.
It looks like you spend a lot of effort and time on your blog.
I have bookmarked it and I am looking forward to reading new articles.Keep up the good work..
PHP Training in Chennai
Selenium Training in Chennai
Digital Marketing Course in Chennai
JAVA Training in Chennai
Java training institute in chennai
Unknown said…
I found great information about asp.net. It is very excellent to every .net developer.
Am very happy to visit this blog.
Dot net Training in Bangalore
menaka13 said…
Good Post and it will definitely help many of us. Really appreciate your work and thanks for sharing with us.

Salesforce Developer Training in Bangalore | Salesforce Developer Course in Bangalore | Salesforce Training in Bangalore | Salesforce Course in Bangalore
cilora said…
Needs to adopt Big Data course to move your career into the data science field? Get Big Data Hadoop Training in Bangalore from TIB Academy to profit your free demo and enroll now to get amazing offers. We provide classroom training and online training on both weekdays and ends of the week dependent on your availability.

Hadoop Training in Bangalore | Hadoop Corse in Bangalore | Hadoop Training Institute in Bangalore

Popular posts from this blog

Asynchronous Socket Programming in C#

Url Routing MVC TUTORIAL

WCF Chat Sample