<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tech Insight ! &#187; MVC</title>
	<atom:link href="http://techinsight.dhanashree.com/category/mvc/feed/" rel="self" type="application/rss+xml" />
	<link>http://techinsight.dhanashree.com</link>
	<description>Technical blog on ASP.Net, PHP, Web Development, Web hosting , Database Programming</description>
	<lastBuildDate>Fri, 12 Aug 2011 07:26:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Understanding asp.net MVC (Model View Controller) architecture</title>
		<link>http://techinsight.dhanashree.com/understanding-asp-net-mvc-model-view-controller-architecture/</link>
		<comments>http://techinsight.dhanashree.com/understanding-asp-net-mvc-model-view-controller-architecture/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 06:21:38 +0000</pubDate>
		<dc:creator>kiran</dc:creator>
				<category><![CDATA[.net 3.5]]></category>
		<category><![CDATA[.net framework]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Web Developement]]></category>
		<category><![CDATA[.net developement]]></category>

		<guid isPermaLink="false">http://techinsight.dhanashree.com/understanding-asp-net-mvc-model-view-controller-architecture/</guid>
		<description><![CDATA[This article is intended to provide basic concept and fundamentals of asp.net MVC (Model View Controller) architecture workflow for beginners.
Introduction:

&#8220;M&#8221;  &#8220;V&#8221;   &#8220;C&#8221;  stands for &#8220;MODEL&#8221;  &#8220;VIEW&#8221; &#8220;CONTROLLER&#8221; , asp.net MVC is an architecture to develop asp.net web applications in a different manner than the traditional asp.net web development , web [...]]]></description>
			<content:encoded><![CDATA[<p>This article is intended to provide basic concept and fundamentals of asp.net MVC (Model View Controller) architecture workflow for beginners.</p>
<p><span style="text-decoration: underline;">Introduction:<br />
</span></p>
<p>&#8220;M&#8221;  &#8220;V&#8221;   &#8220;C&#8221;  stands for &#8220;MODEL&#8221;  &#8220;VIEW&#8221; &#8220;CONTROLLER&#8221; , 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 is even more SEO (Search Engine Friendly ) friendly.</p>
<p>Developing asp.net MVC application requires Microsoft .net framework 3.5 or higher.</p>
<p><span style="text-decoration: underline;">MVC interaction with browser:<br />
</span></p>
<p>Like a normal web server interaction, MVC application also accept request and respond web browser same way.</p>
<p><img src="http://techinsight.dhanashree.com/article-images/020510_0621_Understandi1.png" alt="" /></p>
<p><span style="text-decoration: underline;">Inside MVC architecture:<br />
</span></p>
<p>Whole asp.net MVC architecture is based on Microsoft .net framework 3.5 and in addition uses LINQ to SQL Server.</p>
<p><strong>What is a Model? </strong></p>
<ol>
<li>MVC <strong>model</strong> is basically a C# or VB.net class</li>
<li>A <strong>model</strong> is accessible by both <strong>controller</strong> and <strong>view</strong></li>
<li>A <strong>model</strong> can be used to pass data from <strong>Controller</strong> to <strong>view</strong>.</li>
<li>A <strong>view</strong> can use model to display data in page.</li>
</ol>
<p><strong>What is a View?<br />
</strong></p>
<ol>
<li>View is an ASPX page without having a code behind file</li>
<li>All page specific HTML generation and formatting can be done inside view</li>
<li>One can use Inline code (server tags ) to develop dynamic pages</li>
<li>A request to <strong>view</strong> (ASPX page) can be made only from a controller&#8217;s action method</li>
</ol>
<p><strong>What is a Controller?<br />
</strong></p>
<ol>
<li><strong>Controller</strong> is basically a C# or VB.net class which inherits <strong>system.mvc.controller</strong></li>
<li><strong>Controller</strong> is a heart of whole MVC architecture</li>
<li>Inside<strong> Controller&#8217;s class </strong>action methods can be implemented which is responsible for responding to browser OR calling view&#8217;s.<strong><br />
</strong></li>
<li><strong>Controller</strong> can access and use <strong>model</strong> class to pass data to <strong>view&#8217;s<br />
</strong></li>
<li><strong>Controller </strong>uses <strong>ViewData </strong>to pass any data to <strong>view</strong></li>
</ol>
<p><img src="http://techinsight.dhanashree.com/article-images/020510_0621_Understandi2.png" alt="" /></p>
<h3><span style="text-decoration: underline;"><span style="font-weight: normal;">MVC file structure &amp; file naming standards</span><br />
</span></h3>
<p>MVC uses a standard directory structure and file naming standards which is very important part of MVC application development.</p>
<p>Inside the ROOT directory of the application there must be 3 directories each for model, view and Controller.</p>
<p>Apart from 3 directories there must have a <strong>Global.asax </strong>file in root folder. And a web.config like a traditional asp.net application.</p>
<ul>
<li>
<div><strong>Root </strong>[directory]<strong><br />
</strong></div>
<ul>
<li>
<div><strong>Controller</strong> [directory]</div>
<ul>
<li>Controller CS files</li>
</ul>
</li>
<li>
<div><strong>Models</strong> [directory]</div>
<ul>
<li>Model CS files</li>
</ul>
</li>
<li>
<div><strong>Views </strong>[directory]<strong><br />
</strong></div>
<ul>
<li>View CS files<strong><br />
</strong></li>
</ul>
</li>
<li>Global.asax</li>
<li>Web.config</li>
</ul>
</li>
</ul>
<p><span style="text-decoration: underline;">Asp.net MVC Execution life cycle<br />
</span></p>
<p>Here is how MVC architecture executes the requests to browser and objects interactions with each other.</p>
<p>A step by step process is explained below:  <strong>[Refer figure as given below]</strong></p>
<p><img src="http://techinsight.dhanashree.com/article-images/020510_0621_Understandi3.png" alt="" /></p>
<p><span style="color: #0070c0;"><strong>Step 1: </strong><br />
<strong>Browser request</strong><br />
</span></p>
<p>Browser request happens with a specific URL. Let&#8217;s assume that user entering URL like: [xyz.com]/home/index/</p>
<p><span style="color: #0070c0;"><strong>Step 2:  Job of Global.asax &#8211; MVC routing<br />
</strong></span></p>
<p>The specified URL will first get parsed via application_start() method inside Global.asax file. From the requested URL it will parse the <strong>Controller, Action and ID.<br />
</strong></p>
<p>So for [xyz.com]/home/index/:</p>
<p>Controller = home</p>
<p>Action = index()</p>
<p>ID = empty  &#8212; we have not specified ID in [xyz.com]/home/index/, so it will consider as empty string</p>
<p><span style="color: #0070c0;"><strong>Step 3:  Controller and Action methods<br />
</strong></span></p>
<p>MVC now find the <strong>home controller</strong> class in controller directory.  A controller class contains different action methods,</p>
<p>There can be more than one action method, but MVC will only invokes the action method which is been parsed from the URL, its index() in our case.</p>
<p>So something like: <strong>homeController.index() </strong>will happen inside MVC controller class.</p>
<p>Invoking action method can return plain text string OR rendered HTML by using view.</p>
<p><span style="color: #0070c0;"><strong>Step 4:  Call to View (ASPX page)<br />
</strong></span></p>
<p>Invoking view will return <strong>view()</strong> . 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.</p>
<p>In our case controller was <strong>home </strong>and action was <strong>index().</strong> So calling view() will return a rendered HTML from the ASPX page located at <strong>/views/home/index.aspx.<br />
</strong></p>
<p><strong>This is it, the whole process ends here. So this is how MVC architecture works.</strong></p>
<p><span style="font-family: Calibri; font-size: 15px; color: #ff0000;">NOTE<span style="mso-spacerun: yes;"> </span>:</span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">If you are in need of any </span><a href="http://dhanashree.com/web-development-services/asp-php-web-development" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">Web Development</span></a><span style="font-size: 11pt; font-family: Calibri;"> feel free to <span style="text-decoration: underline;"><a href="http://dhanashree.com/contact-web-designing-company" target="_blank">Inquire us</a></span> .<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a></span>. Expertise in <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">Asp.net Development</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">Php Development</a></span>,<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/website-designing" target="_blank">Website designing</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">Open Source customisation</a></span>. <span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a> </span>can be our <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">offshore development company</a></span> / </span><a href="http://dhanashree.com/web-designing-outsource-advantages" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">outsourcing</span></a><span style="font-size: 11pt; font-family: Calibri;"> <span style="text-decoration: underline;"><a href="http://dhanashree.com/dhanashree-web-development-profile" target="_blank">web development company</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">hire dedicated web programmers</a></span>.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">Above information is for knowledge sharing<span style="mso-spacerun: yes;"> </span>if you have problem / issue / suggestion please intimate us with details for proper and prompt action.</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://techinsight.dhanashree.com/understanding-asp-net-mvc-model-view-controller-architecture/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

