{"id":1650,"date":"2019-12-05T06:20:32","date_gmt":"2019-12-05T06:20:32","guid":{"rendered":"https:\/\/studysection.com\/blog\/?p=1650"},"modified":"2019-12-05T06:41:25","modified_gmt":"2019-12-05T06:41:25","slug":"introduction-to-mvc-framework-with-example","status":"publish","type":"post","link":"https:\/\/studysection.com\/blog\/introduction-to-mvc-framework-with-example\/","title":{"rendered":"Introduction to MVC Framework With Example"},"content":{"rendered":"<h2>MVC<\/h2>\n<p>MVC stands for Model View Controller and it is a part of three components namely Model, View, and Controller.<\/p>\n<p><strong>Controller:<\/strong>&#8211; It controls the flow of the application. It works as a mediator between View and Model. It will get a request from View and fetch data from the Model according to View request and respond back to the View.<br \/>\n<strong>View:<\/strong>&#8211; It is used to display data to the user that is present in the Model. To link with Model it will invoke the Controller.<br \/>\n<strong>Model:<\/strong>&#8211; It helps to communicate with the database. It sends data to a database and retrieves data from the database.<\/p>\n<p>For Example,<br \/>\nWhen the user enters URL in the browser, the request will be accepted by the Controller and the Controller will handle the request and communicate with the Model to send data to View to display it to the user.<\/p>\n<ul>\n<li>User interacts with the View<\/li>\n<li>View interacts with the Controller<\/li>\n<li>Controller updates Model about the request of View<\/li>\n<li>Model will return according to Controller request<\/li>\n<li>Controller will send a response back to View. <\/li>\n<\/ul>\n<h3>Features of MVC<\/h3>\n<ul>\n<li>Readability of the code becomes easy<\/li>\n<li>Clean code makes everyone understand the flow<\/li>\n<li>Clear separation of logic, models and HTML code<\/li>\n<li>Code can be reused<\/li>\n<\/ul>\n<h3>Let&#8217;s see an example of Model View Controller from daily life:<\/h3>\n<p>When customers go to a restaurant, a waiter comes and takes orders. It is the duty of the waiter to serve your order but he will not cook the food. He will go to the kitchen and tell the cook what they need to prepare. When the food will be prepared by the cook, he\/she will call the waiter and the waiter will serve the food to the customer.<br \/>\nSo, the same scenario occurs when you create an application. You will need to create frontend code which will be written in View file. Any data that will be needed to show from the database will be passed by Controller to View by fetching data from the Model.<\/p>\n<p>If there is anything common that is needed to be called very often, you can create a helper class for that.<\/p>\n<h3>Why do we need to use MVC?<\/h3>\n<ul>\n<li>MVC is the standard way to create a code. It is a good practice to follow the MVC pattern while coding.<\/li>\n<li>Code can be reused as it is clean and it is easily understood by other <a href=\"https:\/\/studysection.com\/blog\/fundamental-skills-needed-to-become-a-programmer\/\">programmers<\/a>.<\/li>\n<li>Testing can be performed easily.<\/li>\n<li>Security and performance are good.<\/li>\n<\/ul>\n<p><strong>Example<\/strong>: We need to create a simple application according to the following points<\/p>\n<ul>\n<li>Display list of links<\/li>\n<li>Create a form where the user can submit the link<\/li>\n<li>Validate the form<\/li>\n<li>Insert into database<\/li>\n<\/ul>\n<ol>\n<li>To display you need to create a View file with form fields Link, description, and title with a submit button<\/li>\n<li>To validate you need to write code of validation in Controller<\/li>\n<li>To insert the link, description, and title, the code will be written in the Model.<\/li>\n<\/ol>\n<p><small><em>Knowledge of .NET is quite rewarding in the IT industry. If you have got some skills in the .NET framework then a <a href=\"https:\/\/studysection.com\/asp-.net-4.5-advanced\">.NET certification<\/a> from StudySection can prove to be a good attachment with your resume. You can go for a foundation level certificate as well as an advanced level certificate in the .NET framework.<\/em><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>MVC MVC stands for Model View Controller and it is a part of three components namely Model, View, and Controller.<\/p>\n","protected":false},"author":1,"featured_media":1651,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[241,149,161,189,287],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>StudySection Blog - Introduction to MVC Framework With Example<\/title>\n<meta name=\"description\" content=\"MVC stands for Model View Controller and it is a part of three components namely Model, View, and Controller. It controls the flow of the application.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/studysection.com\/blog\/introduction-to-mvc-framework-with-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"StudySection Blog - Introduction to MVC Framework With Example\" \/>\n<meta property=\"og:description\" content=\"MVC stands for Model View Controller and it is a part of three components namely Model, View, and Controller. It controls the flow of the application.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/studysection.com\/blog\/introduction-to-mvc-framework-with-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog Posts on famous people, innovations and educational topics\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/studysection\" \/>\n<meta property=\"article:published_time\" content=\"2019-12-05T06:20:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-12-05T06:41:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2019\/12\/mvc-framework.png\" \/>\n\t<meta property=\"og:image:width\" content=\"300\" \/>\n\t<meta property=\"og:image:height\" content=\"200\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"admin-studysection-blog\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@studysection\" \/>\n<meta name=\"twitter:site\" content=\"@studysection\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin-studysection-blog\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/studysection.com\/blog\/introduction-to-mvc-framework-with-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/studysection.com\/blog\/introduction-to-mvc-framework-with-example\/\"},\"author\":{\"name\":\"admin-studysection-blog\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402\"},\"headline\":\"Introduction to MVC Framework With Example\",\"datePublished\":\"2019-12-05T06:20:32+00:00\",\"dateModified\":\"2019-12-05T06:41:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/studysection.com\/blog\/introduction-to-mvc-framework-with-example\/\"},\"wordCount\":554,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/studysection.com\/blog\/#organization\"},\"keywords\":[\"browser\",\"database\",\"features\",\"Framework\",\"MVC\"],\"articleSection\":[\"Learn and Grow\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/studysection.com\/blog\/introduction-to-mvc-framework-with-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/studysection.com\/blog\/introduction-to-mvc-framework-with-example\/\",\"url\":\"https:\/\/studysection.com\/blog\/introduction-to-mvc-framework-with-example\/\",\"name\":\"StudySection Blog - Introduction to MVC Framework With Example\",\"isPartOf\":{\"@id\":\"https:\/\/studysection.com\/blog\/#website\"},\"datePublished\":\"2019-12-05T06:20:32+00:00\",\"dateModified\":\"2019-12-05T06:41:25+00:00\",\"description\":\"MVC stands for Model View Controller and it is a part of three components namely Model, View, and Controller. It controls the flow of the application.\",\"breadcrumb\":{\"@id\":\"https:\/\/studysection.com\/blog\/introduction-to-mvc-framework-with-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/studysection.com\/blog\/introduction-to-mvc-framework-with-example\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/studysection.com\/blog\/introduction-to-mvc-framework-with-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/studysection.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Introduction to MVC Framework With Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/studysection.com\/blog\/#website\",\"url\":\"https:\/\/studysection.com\/blog\/\",\"name\":\"Blog Posts on famous people, innovations and educational topics\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/studysection.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/studysection.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/studysection.com\/blog\/#organization\",\"name\":\"StudySection\",\"url\":\"https:\/\/studysection.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png\",\"contentUrl\":\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png\",\"width\":920,\"height\":440,\"caption\":\"StudySection\"},\"image\":{\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/studysection\",\"https:\/\/twitter.com\/studysection\",\"https:\/\/www.instagram.com\/study.section\/\",\"https:\/\/www.linkedin.com\/company\/studysection\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402\",\"name\":\"admin-studysection-blog\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g\",\"caption\":\"admin-studysection-blog\"},\"url\":\"https:\/\/studysection.com\/blog\/author\/admin-studysection-blog\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"StudySection Blog - Introduction to MVC Framework With Example","description":"MVC stands for Model View Controller and it is a part of three components namely Model, View, and Controller. It controls the flow of the application.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/studysection.com\/blog\/introduction-to-mvc-framework-with-example\/","og_locale":"en_US","og_type":"article","og_title":"StudySection Blog - Introduction to MVC Framework With Example","og_description":"MVC stands for Model View Controller and it is a part of three components namely Model, View, and Controller. It controls the flow of the application.","og_url":"https:\/\/studysection.com\/blog\/introduction-to-mvc-framework-with-example\/","og_site_name":"Blog Posts on famous people, innovations and educational topics","article_publisher":"https:\/\/www.facebook.com\/studysection","article_published_time":"2019-12-05T06:20:32+00:00","article_modified_time":"2019-12-05T06:41:25+00:00","og_image":[{"width":300,"height":200,"url":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2019\/12\/mvc-framework.png","type":"image\/png"}],"author":"admin-studysection-blog","twitter_card":"summary_large_image","twitter_creator":"@studysection","twitter_site":"@studysection","twitter_misc":{"Written by":"admin-studysection-blog","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/studysection.com\/blog\/introduction-to-mvc-framework-with-example\/#article","isPartOf":{"@id":"https:\/\/studysection.com\/blog\/introduction-to-mvc-framework-with-example\/"},"author":{"name":"admin-studysection-blog","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402"},"headline":"Introduction to MVC Framework With Example","datePublished":"2019-12-05T06:20:32+00:00","dateModified":"2019-12-05T06:41:25+00:00","mainEntityOfPage":{"@id":"https:\/\/studysection.com\/blog\/introduction-to-mvc-framework-with-example\/"},"wordCount":554,"commentCount":0,"publisher":{"@id":"https:\/\/studysection.com\/blog\/#organization"},"keywords":["browser","database","features","Framework","MVC"],"articleSection":["Learn and Grow"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/studysection.com\/blog\/introduction-to-mvc-framework-with-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/studysection.com\/blog\/introduction-to-mvc-framework-with-example\/","url":"https:\/\/studysection.com\/blog\/introduction-to-mvc-framework-with-example\/","name":"StudySection Blog - Introduction to MVC Framework With Example","isPartOf":{"@id":"https:\/\/studysection.com\/blog\/#website"},"datePublished":"2019-12-05T06:20:32+00:00","dateModified":"2019-12-05T06:41:25+00:00","description":"MVC stands for Model View Controller and it is a part of three components namely Model, View, and Controller. It controls the flow of the application.","breadcrumb":{"@id":"https:\/\/studysection.com\/blog\/introduction-to-mvc-framework-with-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/studysection.com\/blog\/introduction-to-mvc-framework-with-example\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/studysection.com\/blog\/introduction-to-mvc-framework-with-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/studysection.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Introduction to MVC Framework With Example"}]},{"@type":"WebSite","@id":"https:\/\/studysection.com\/blog\/#website","url":"https:\/\/studysection.com\/blog\/","name":"Blog Posts on famous people, innovations and educational topics","description":"","publisher":{"@id":"https:\/\/studysection.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/studysection.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/studysection.com\/blog\/#organization","name":"StudySection","url":"https:\/\/studysection.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png","contentUrl":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png","width":920,"height":440,"caption":"StudySection"},"image":{"@id":"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/studysection","https:\/\/twitter.com\/studysection","https:\/\/www.instagram.com\/study.section\/","https:\/\/www.linkedin.com\/company\/studysection"]},{"@type":"Person","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402","name":"admin-studysection-blog","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g","caption":"admin-studysection-blog"},"url":"https:\/\/studysection.com\/blog\/author\/admin-studysection-blog\/"}]}},"views":659,"_links":{"self":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/1650"}],"collection":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/comments?post=1650"}],"version-history":[{"count":4,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/1650\/revisions"}],"predecessor-version":[{"id":1653,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/1650\/revisions\/1653"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/media\/1651"}],"wp:attachment":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/media?parent=1650"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/categories?post=1650"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/tags?post=1650"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}