Indiandotnet – Microsoft user group community
http://indiandotnet.wordpress.com
https://facebook.com/indiandotnet
https://sqlraaga.blogspot.com
M V C
“M” “V” “C” stands for “MODEL” “VIEW” “CONTROLLER”. A Software Design Pattern.
Introduced in 1970s.
It makes it easier to manage complexity.
Separation of concerns(Soc).
Used by Ruby on Rails, Spring Framework, Apple iOS
ASP.Net MVCASP.Net MVC
ASP.NET MVC is an open source framework built on the top of Microsoft .NET Framework.
Use to build the Web Application Based on MVC
ASP.NET MVC framework is the most customizable and extensible platform shipped by Microsoft.
How works with ASP.Net MVCHow works with ASP.Net MVC
ViewModel or Strongly type model
Business Layer or Model
Data Access Layer
View in ASP.NET MVC
Controller in ASP.NET MVC
AdvantagesAdvantages
TDD State Less Front controller pattern Extensible and pluggable Full control over application behaviour ASP.NET features are supported URL routing mechanism Support with jquery libraries.
ASP.NET MVC VS WEB FORMSASP.NET MVC VS WEB FORMS
ASP.NET Web Forms ASP.NET MVCASP.NET Web Forms uses Page controller. ASP.NET MVC uses Front Controller
approach. No separation of concerns. Very clean separation of concerns. View
and Controller are neatly separate.Generally follow URL structure containing page name. (E.g.: http://mywebsite.com/default.aspx)
Has rich Routing structure.(E.g: http://mywebsite.com/home/index)
Follows a traditional event driven development model.
Asp. Net MVC is a lightweight and follow MVC pattern based development model.
Contains server controls. Contains Html helpers.Default state management (like as view state, session) techniques.
No automatic state management techniques.
User Controls for code re-usability. Partial Views for code re-usability.
Demo project startup
Introduction
Project Folder
Model ,View ,Controller
Razor View Engine
Html Helper
Demo project startup
Introduction
Bundle Config
Filter Config
Route Config
WebApi Config
Area in MVC
Style & Scripts Folder
Views
Layouts RenderBody
RenderPage
RenderSection
Styles.Render
Scripts.Render
Sections
Define Layout ViewStart Page
With in view
Return type
Views
Normal View How to render view - Demo
Partial View Html.Partial
How to render by jquery
How add on page
Strongly Typed View How to use it
HTML Helpers
Standard Html Helpers
Strongly Typed HTML Helpers
Template HTML Helpers
URL Helpers
AJAX Helpers
Controller
Action ResultViewResult
PartialViewResult
RedirectResult
RedirectToRouteResult
ContentResult
JsonResult
JavaScriptResult
FileResult
Action MethodsNon-Action Attribute
HttpGet
HttpPost
FilterAuthentication Filter
Authorization Filter
Action Filter
Result Filter
Exception Filter
Top Related