390 likes | 519 Views
ASP.NET Web Forms. ASP.NET MVC. MVC – What’s all the fuss?. Presented by @ EricPhan – Solution Architect @ SSW. Eric Phan – SA @ SSW. w: ericphan.info | e: EricPhan @ssw.com.au | t: @ ericphan. Application architecture SQL Performance Tuning Certified Scrum Master
E N D
ASP.NET Web Forms ASP.NET MVC MVC – What’s all the fuss? Presented by @EricPhan – Solution Architect @ SSW Delivering Awesome Web Applications
Eric Phan – SA @ SSW w: ericphan.info | e: EricPhan@ssw.com.au | t: @ericphan • Application architecture • SQL Performance Tuning • Certified Scrum Master • Technology aficionado • Silverlight (RIP) • Windows Forms (RIP) • ASP.NET + MVC • CRM • Business Intelligence
Agenda A brief history of the Microsoft web platform • ASP Classic • ASP.NET Web Forms • ASP.NET MVC Why clients and devs choose MVC Common MVC questions • Third Party Tools • Learning Curve • Migration Q&A
It was VB scripting for the web • Does the term spaghetti coding ring a bell? • ActiveX and COM hell • Deployments/Updates usually involved stopping IIS • Avert your eyes now… <%Response.Write("<h1>Multiplication table</h1>")Response.Write("<table border=2 width=50%") Fori = 1 to 9 response.write("<tr>")response.write("<td>" & i & "</td>")For j = 2 to 9 response.write("<td>" & i * j & "</td>")Nextresponse.write("</tr>")Nextresponse.write("</table>") %>
Problems with Classic ASP • Interpreted (more runtime errors) • Testing was Edit, Save, Load Page, rinse and repeat • Logic and UI on a single page • If you wanted to move logic out you created COM objects • Poor performance • Poor architecture (1 tiered)
Windows Forms for the Web • Separated the HTML from the Server Side Code (*.aspx, *.aspx.cs, *.aspx.vb) • Compiled & Strongly typed • Better performance • Xcopy deployment • Better performance • C# Support!!! • New features: • Event Driven • Caching • Server side controls • Data binding • Web Services • State Management • Drag and drop controls
Problems with ASP.NET Web Forms • Gigantic View State • False sense of separation of UI and Code • Difficult to write unit tests against the web project • Limited control of the HTML output • URLs • Dodgy designer • In depth knowledge of the Page Lifecycle
View and code separation out of the box • Shorter pipeline/life cycle • Fully unit testable • Full control over HTML output • SEO friendly URLs • Small footprint • Web API • JSON support • NuGet • Mobile targeting • Bundling + Minification • Extensible – Don’t like Razor? Write your own view engine • Convention over configuration
Problems with ASP.NET MVC • Initial cost of the first page • Lots of conventions • Fingers get good exercise • No Designer
<table> <thead> <trclass="thead"> <th>Distributor</th> <th>Account Code</th> <th>Name</th> <th>Address</th> <th>Terminal ID</th> <th></th> </tr> </thead> @foreach (var item inModel.Customers) { <tr> <td>@Html.DisplayFor(modelItem => item.Distributor)</td> <td>@Html.DisplayFor(modelItem => item.AccountCode)</td> <td>@Html.DisplayFor(modelItem => item.Name)</td> <td>@(item.Address == ", -1" ? "" : item.Address)</td> <td>@Html.DisplayFor(modelItem => item.TerminalId)</td> <td>@Html.ActionLink(item.Links > 0 ? "Edit (" + item.Links + ")" : "Assign", "Edit", new { id = item.CustomerId })</td> </tr> }
<table> <thead> <trclass="thead"> <th>Distributor</th> <th>Account Code</th> <th>Name</th> <th>Address</th> <th>Terminal ID</th> <th></th> </tr> </thead> @foreach (var item inModel.Customers) { <tr> <td>@Html.DisplayFor(modelItem => item.Distributor)</td> <td>@Html.DisplayFor(modelItem => item.AccountCode)</td> <td>@Html.DisplayFor(modelItem => item.Name)</td> <td>@(item.Address == ", -1" ? "" : item.Address)</td> <td>@Html.DisplayFor(modelItem => item.TerminalId)</td> <td>@Html.ActionLink(item.Links > 0 ? "Edit (" + item.Links + ")" : "Assign", "Edit", new { id = item.CustomerId })</td> </tr> }
Nice URLs SharePoint 2010 Document Library http://sharepoint.ssw.com.au/Training/UTSSQL/Documents/Forms/AllItems.aspx?RootFolder=%2FTraining%2FUTSSQL%2FDocuments%2FLatest&FolderCTID=0x0120002E151A03AD819A4D8F3C2EE85587E36E&View={A8CF0D12-F1EC-401B-B48A-E135549EB5C4} MVC – SSW TimePro https://timepro.ssw.com.au/Timesheet/EP https://timepro.ssw.com.au/Timesheet/EP/Week https://timepro.ssw.com.au/Timesheet/EP/2012-05-29/Add https://timepro.ssw.com.au/Account/Settings https://timepro.ssw.com.au/Report/MissingTimesheets/2012-5-28
ALL JUNK – About 8000 bytes The relevant data
Some statistics http://trends.builtwith.com/framework/ASP.NET
Some statistics http://trends.builtwith.com/framework/ASP.NET-MVC
Jobs http://www.indeed.com/jobanalytics/jobtrends?q=asp.net&l=
Jobs http://www.indeed.com/jobtrends?q=mvc&l=
MVC Adoption • All our greenfield projects are MVC unless: • We are integrating with some framework (e.g. CMS system) • Developers generally fall in love with MVC once they start using it • On the cusp of a sea change
MVC Features • Web API – RESTful services with little effort • URL routing & Managed URLs (can be used with ASP.NET WebForms) • Filters (easily add error handling and logging) • Content bundling • Sections • NuGet • Mobile targeting • Open Source • Features developed for MVC then ported back to ASP.NET (URL)
Awesome NuGet Packages • Glimpse • MobileViewEngines (MVC3, built into MVC4) • MiniProfiler • MvcMailer • MvcDonutCaching
Common Questions • Third Party Controls? • Telerik • MVC Toolkit • Infragistics • ComponentArt • ComponentOne • Javascript based: • jQuery + jQueryUI (bundled) • KendoUI • KnockoutJS • Twitter Bootstrap
Common Questions • Migrating from ASP.NET? • Run MVC & Web Forms side by side • Just migrate new functionality to MVC • Migrate any page that you touch to MVC
Common Questions • Learning curve? • Statelessness • Lots more jQuery • Raw HTML • Conventions (more files, View, Model, Controller, Display and EditorTemplates) • Allow a couple of months to become comfortable
So ASP.NET or MVC? http://programmers.stackexchange.com/questions/95212/when-to-favor-webforms-over-mvc
Want to learn more about ASP.NET MVC? • ASP.NET MVC • http://www.asp.net/mvc/mvc4 • A look at ASP.NET MVC 4 - Scott Guthrie • http://channel9.msdn.com/Events/TechDays/Techdays-2012-the-Netherlands/2364 • Zero to Everywhere with ASP.NET MVC – Damian Brady • http://r.ssw.com/mvc-mobile
MVC Courses • MVC for Enterprise Apps Part I - $330 + GST • http://r.ssw.com/mvc-1 • Free license: • Kendo UI - $399 • Just Code - $249 • MVC for Enterprise Apps Part II - $330 + GST • http://r.ssw.com/mvc-2
3things… • EricPhan@ssw.com.au • http://ericphan.info/ • twitter.com/ericphan
Thank You! Sydney | Melbourne | Brisbane | Adelaide info@ssw.com.au www.ssw.com.au