340 likes | 641 Views
Building Web Apps with ASP.NET Jump Start. Scott Hanselman Jon Galloway. Meet Scott Hanselman | @ shanselman. Principal Program Manager, Microsoft Web developer focused on Windows Azure and ASP.NET Blogging at http://hanselman.com for over a decade
E N D
Building Web Apps with ASP.NET Jump Start Scott Hanselman Jon Galloway
Meet Scott Hanselman | @shanselman Principal Program Manager, Microsoft Web developer focused on Windows Azure and ASP.NET Blogging at http://hanselman.com for over a decade One of Microsoft’s Most Respected Developers Written a number of books and spoken in person to almost a half million developers worldwide http://hanselminutes.com for tech talk http://thisdeveloperslife.com on developers’ lives and loves http://ratchetandthegeek.com for pop culture and tech media
Meet Jon Galloway | @jongalloway Windows Azure Technical Evangelist Focused on ASP.NET MVC http://weblogs.asp.net/jgalloway Web development on Microsoft platform since late '90s Ex-submariner; Showcase Showdown winner “Price is Right” Popular Author and Conference Speaker WroxProfessional MVC 4; MVC Music Store tutorial Virtual ASP.NET MVC Conference (mvcConf) First Web Camps World Tour in 2010 Herding Code podcast (http://herdingcode.com)
Damian Edwards | @damianedwards ASP.NET Program Manager Focused on ASP.NET Core, Web Forms and SignalR http://twitter.com/damianedwards Australian trapped in Seattle Worked for an Ambulance company! Invented SignalR with David Fowler, and created WebFormsMVP Conference Speaker TechEd, BUILD, DevConnections and more! And a lovely billiards player
Building Web Apps with ASP.NET Jump Start • Target Audience • Experienced application developers interested in leveraging ASP.NET and Visual Studio 2012 to offer modern apps that target modern browsers • Suggested Prerequisites • At least six months of professional app dev experience • Previous Jump Starts:Developing in HTML5 with JavaScript and CSS3Developing Windows Store Apps with HTML5
Join the MVA Community! Microsoft Virtual Academy Free online learning tailored for IT Pros and Developers Over 1M registered users Up-to-date, relevant training on variety of Microsoft products “Earn while you learn!” Get 50 MVA Points for this event! Visit http://aka.ms/MVA-Voucher Enter this code: ASPWebAppsJS(expires 3/8/2013)
Introduction: ASP.NET Foundations and Scenarios Jon GallowayScott Hanselman
Module Overview ASP.NET 4.5 Web Forms Visual Studio 2012 features for web devs Bundling & Optimization
Visual Studio 2012: The editor for serious web dev HTML5 / CSS3 standards and smarts JavaScript language features Page Inspector One code editor for client and server Web Essentials extension
NuGet: The smart, easy way to manage dependencies Find the latest release Install and configure in your project Handle dependencies and versions Updates with dependency checking Common list of installed packages Simplified uninstalls Streamlined deployment with Package Restore
One ASP.NET: A Framework for us all Sites Services Web Forms Web Pages SignalR Single Page Apps MVC Web API ASP.NET
ASP.NET and Web Tools 2012.2 Adds new project templates to Visual Studio No changes to ASP.NET runtime, instead adds NuGet packages Lightweight install (<10 minutes, no reboot) Download and information: http://asp.net/vnext
Deploying ASP.NET Apps to the Cloud Windows Azure Web Sites (10 free!) Fast site creation and deployment Nothing new to learn Easy to scale
What’s New in ASP.NET 4.5 Jon GallowayScott Hanselman
Moving towards a goal - One ASP.NET Sites Services Web Forms Web Pages SignalR Single Page Apps MVC Web API ASP.NET
Module Overview Web Forms: Strongly Typed Data Controls Web Forms: Model Binding Friendly URLs Page Inspector Visual Studio web editor features Web Essentials Bundling & Optimization Async everywhere! (BONUS!)
Model Binding with ASP.NET Web Forms:Strongly Typed Data Controls Step 1: Set the ItemType <ul> <asp:Repeater ID="customersRepeater" runat="server" ItemType="WebFormsLab.Model.Customer"> </asp:Repeater> </ul> Step 2: Reference the properties as needed using the Item keyword <ul> <asp:Repeater ID="customersRepeater" runat="server“ ItemType="WebFormsLab.Model.Customer"> <ItemTemplate> <li> <a href="CustomerDetails.aspx?id=<%#: Item.Id %>"> <%#: Item.FirstName %> <%#: Item.LastName %> </a> </li> </ItemTemplate> </asp:Repeater> </ul>
Web Forms: Model BindingGetting Data <ul> <asp:Repeater ID="customersRepeater" runat="server" ItemType="WebFormsLab.Model.Customer"SelectMethod="GetCustomers"> </asp:Repeater> </ul> Step 1: Set Select Method • public IQueryable<Customer> GetCustomers([Control]DateTime? createdSince) • { • IQueryable<Customer> query = _db.Customers; • if (createdSince.HasValue) • { • query = query.Where( • i => i.CreatedOn >= createdSince.Value); • } • return query; • } Step 2: Get method returns IEnumerable or IQueryable
Web Forms: Model BindingInserting Data <asp:FormViewrunat="server" ID="customerForm" InsertMethod="InsertCustomer"UpdateMethod="UpdateCustomer" <EditItemTemplate> <asp:Labelrunat="server" Text="Name:" AssociatedControlID="Name" /> <asp:TextBoxrunat="server" ID="Name" Text="<%# BindItem.Name %>" /> <!-- etc. --> Step 1: Set Insert Method public void InsertCustomer() { var customer = new Customer(); TryUpdateModel(customer); if (ModelState.IsValid) { _db.Customers.Add(customer); SaveChanges(customer); } } Step 2: Use TryUpdateModel to validate, then save
Web Forms: Friendly URLs public Album EditAlbum_GetItem([FriendlyUrlSegments]int? id) { return _db.Albums.Find(id); } /Album/Edit/1 \Album\Edit.aspx ID passed to controls Segments can be bound or accessed programmatically
Bundling and Optimization Web pages have many external references: CSS, Images, JavaScript
Bundling and Optimization Bundling combines CSS and JavaScript requests
Bundling and Optimization Minification compresses the files before sending