Your SlideShare is downloading. ×
Mvc presentation
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Mvc presentation

538
views

Published on

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
538
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
19
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • http://msdn.microsoft.com/en-us/library/75x4ha6s.aspx
  • http://msdn.microsoft.com/en-us/magazine/dd252940.aspx
  • Transcript

    • 1. Asp.net Mvc Brandon D’Imperio bdimpe@gmail.com Imaginarydevelopment.comImaginarydevelopment.blogspot.com
    • 2. What’s wrong with WebForms?• Web Forms allow developers to rapidly create applications simply by dragging and dropping controls and handling page-level events for both the page and the controls on the page. This works well, but it’s a high-level of abstraction and many developers completely forget—or never learned—how the HTML layout actually works behind the scenes. As a result, it’s common to end up with non-validating HTML, or bloated and hard-to-manage HTML layout that is very designer unfriendly. Add to that a huge amount of ViewState if you don’t effectively manage ViewState properly and you can easily end up with pages that are much bigger than they need to be and slow as molasses.• One downside of the Web Forms framework is that behind this abstraction layer, Microsoft built a very complex engine that has many side effects in the Page pipeline. If you’ve ever built complex pages that contain many components on the page it can sometimes get very difficult to coordinate the event sequence for data binding, rendering, and setup of the various controls at the correct time in the page cycle. Do you load data in the Init, Load or PreRender events or do you assign values during postback events? Web Forms need to run through a single server-side form so they can’t easily be broken up into smaller logical units. In complex forms, event handlers can get very bulky with the tasks they need to handle and often in ways that can’t be easily refactored so you end up with code that is difficult to maintain and impossible to test. – Rick Strahl – MVP since 1997
    • 3. Webforms?
    • 4. Who uses MVC?• StackOverflow.com – Serves 1.4-1.5 million hits per day. (as of May, 2010) – A language-independent collaboratively edited question and answer site for programmers. Questions and answers displayed by user votes and tags. – Alexa traffic ranked 465, 451 in the US, and 212 in India• Its no coincidence that many of the most popular web programming frameworks also encapsulate MVC principles: Django, Ruby on Rails, CakePHP, Struts, and so forth. Its also officially creeping into ASP.NET under the fledgling ASP.NET MVC project. – Jeff Atwood of CodingHorror.com May,2008
    • 5. MVC vs webforms• ASP.net MVC – Enables the full control over the rendered HTML. – Provides clean separation of concerns(SoC). – Enables Test Driven Development (TDD). – Easy integration with JavaScript frameworks. – Following the design of stateless nature of the web. – RESTful urls that enables SEO. – No ViewState and PostBack events • Lightweight/faster – No Codebehind• ASP.net Web Forms – It provides RAD development – Easy development model for developers coming from winform development.
    • 6. MVC + webforms• You can intermix the two• Use MVC for routing, separation, more javascript/jQuery friendliness• Use webforms for complex controls that you are attached to or are just better for the situation.• Both use some T4 style-coding
    • 7. What is M.V.C?• Model – The classes which are used to store and manipulate state, typically in a database of some kind.• View – Your application’s presentation code or layer• Controller – Wires up your model to your View/presentation/public interface (winforms, web pages, web services, soap, rest, etc..)
    • 8. How does it work?
    • 9. Web forms flow vs. MVC flow
    • 10. Asp.net MVC with routingUser does a Get or Post to the routingsystem. The routing system tries tofind a route match, and creates aninstance of the appropriate controller.Then it invokes the Action on thecontroller.The controller invokes methods on themodel, which passes back any relevantdata used in response.The controller then usually locates theview and renders the view using thedata from the model (in many casestransformed or flattened in aViewModel or in the controller) .
    • 11. Sample Layout • Controllers – Define your externally visible methods/URLs • Models – Your Core code + persistence • Views – Pages to render • Global.asax (not pictured) – Defines routes, and other app-startup code
    • 12. References• What’s Ailing Asp.Net Web Forms – Rick Strahl• http://www.codinghorror.com/blog/2008/05/ understanding-model-view-controller.html• http://www.aspiringcraftsman.com/2007/08/i nteractive-application-architecture/