ASP.NET MVC Tips and Tricks Al Wilkinson. Hi! I’m Al  First program in Logo in 1985 in 1st grade #loveatfirstbyte  Started HTML in 1996, led to web.

Slides:



Advertisements
Similar presentations
Sharpen Your MVC Views with Razor By Jon Marozick.
Advertisements

ASP.NET Best Practices Dawit Wubshet Park University.
Introduction to MVC Adding a View Page NTPCUG Tom Perkins, Ph.D.
Web Development in Microsoft Visual Studio Slide 2 Lecture Overview Introduce Visual Studio 2013 Create a first ASP.NET application.
Building a Complete Web Application Using ASP.NET 3.5 & Visual Studio 2008 (Part 1 of 2) Jeff King Program Manager Microsoft Corporation
Microsoft ASP.NET AJAX - AJAX as it has to be Presented by : Rana Vijayasimha Nalla CSCE Grad Student.
SharePoint Saturday Sponsors Gold Bronze Custom REST services and jQuery AJAX Building your own custom REST services and consuming them with jQuery AJAX.
SharePoint Mobile Improving efficiency of the mobile workforce Anthony Pham Product Support Manager KWizCom
What’s new in ASP.NET MVC 3 Building a NerdDinner/AppStore Application.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Kay Herzam Herzam IT Consulting What‘s new in ASP.NET MS TechTalk.
Windows.Net Programming Series Preview. Course Schedule CourseDate Microsoft.Net Fundamentals 01/13/2014 Microsoft Windows/Web Fundamentals 01/20/2014.
Ori Calvo, 2010 “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie,
Web & Cloud Development Jason Keicher - Microsoft.
OAuth-as-a-service using ASP.NET Web API and Windows Azure Access Control Maarten
NextGen Technology upgrade – Synerizip - Sandeep Kamble.
CodeIgniter - [Overview]
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
SUNY Polytechnic Institute CS 490 – Web Design, AJAX, jQueryAngularJS AngularJS is a client-side JavaScript Framework for adding interactivity to HTML.
Joel Bapaga on Web Design Strategies Technologies Commercial Value.
CIS 375—Web App Dev II ASP.NET 2 Introducing Web Forms.
ASP.NET 5 Visual Studio 2015 Templates Bill Wolff Rob Keiser June 10, 2015.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Moving from Web-based Collaboration to the Mobile Arena Nimrod Geva Product Group Manager, KWizCom
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
LiveCycle Data Services Introduction Part 2. Part 2? This is the second in our series on LiveCycle Data Services. If you missed our first presentation,
 You’re already a Web Site Dev  You’re interested in more simply making your web sites more responsive  If you’re not already hosting sites in.
Introduction to ASP.NET MVC Information for this presentation was taken from Pluralsight Building Applications with ASP.NET MVC 4.
Sponsors Gold Silver Bronze Custom REST services and jQuery AJAX Building your own custom REST services and consuming them with jQuery AJAX.
NMD202 Web Scripting Week3. What we will cover today Includes Exercises PHP Forms Exercises Server side validation Exercises.
OWASP Top Ten #1 Unvalidated Input. Agenda What is the OWASP Top 10? Where can I find it? What is Unvalidated Input? What environments are effected? How.
Sponsors Gold Silver Bronze Custom REST services and jQuery AJAX Building your own custom REST services and consuming them with jQuery AJAX.
Jeff King Senior Program Manager Microsoft Session Code: WIA204.
PERFORMANCE ENHANCEMENT IN ASP.NET By Hassan Tariq Session #1.
Getting started with ASP.NET MVC Dhananjay
Canopy walk through Single-Page Apps (SPAs) Benjamin Howarth Freelancer, Code Gecko Umbraco UK Festival, Fri 30 th Oct 2015 CODE GECKO.
MBL 305 ASP.NET Mobile Controls: Best Practices Gökşin Bakir CSA Yage Ltd. Microsoft Regional Director.
ICM – API Server & Forms Gary Ratcliffe.
Securing Angular Apps Brian Noyes
UNDERSTANDING YOUR OPTIONS FOR CLIENT-SIDE DEVELOPMENT IN OFFICE 365 Mark Rackley
Bundles, Minification Andres Käver, IT Kolledž
Working with Data Model Binders, Display Templates, Editor Templates, Validation… SoftUni Team Technical Trainers Software University
Virtual techdays INDIA │ 9-11 February 2011 SESSION TITLE Kamala Rajan S │ Technical Manager, Marlabs.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
AJAX CS456 Fall Examples Where is AJAX used? Why do we care?
Leveraging Web Content Management in SharePoint 2013 Christina Wheeler.
Nivo 300 ASP.NET MVC 4 Danijel Malik Artifis Danijel Malik s.p.
Modern Development Technologies in SharePoint SHAREPOINT SATURDAY OMAHA APRIL, 2016.
Bob German Principal Architect Developing SharePoint Applications with MVC and Entity Framework.
Danijel Malik Visual Studio ALM MVP What’s new in Visual Studio 2013 and Team Foundation Server 2013.
BIT 286: Web Applications ASP.Net MVC. Objectives Applied MVC overview Controllers Intro to Routing Views ‘Convention over configuration’ Layout files.
//liveVirtualacademy2011/ What’s New for ASP.NET 4.5 and Web Development in Visual Studio 11 Developer Preview Γιώργος Καπνιάς MVP, MCT, MCDP, MCDBA, MCTS,
AngularJS and SharePoint
© Copyright SELA software & Education Labs Ltd Baruch Hirsch St.Bnei Brak Israel
Top 10 Entity Framework Features Every Developer Should Know
Introducing the Microsoft® .NET Framework
About Bill Bill Baer (ˈbɛər)
TechEd /1/2018 7:56 AM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
ASP MVP Web applications and Razor
ASP.NET MVC Introduction
ASP.NET Core* 1.0 The Future of Web Apps Shahed Chowdhuri
PHP Training at GoLogica in Bangalore
MVC in ASP.NET Core: The new kid on the block
Microsoft Build /11/2018 2:12 AM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY,
Continuous Automated Chatbot Testing
A Quick Overview of ASP.NET Core 1.0
TechEd /22/2019 9:22 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
07 | Introduction to Authentication
Erik Porter Program Manager ASP.NET Microsoft Corporation
#01# ASP.NET Core Overview Design by: TEDU Trainer: Bach Ngoc Toan
Presentation transcript:

ASP.NET MVC Tips and Tricks Al Wilkinson

Hi! I’m Al  First program in Logo in 1985 in 1st grade #loveatfirstbyte  Started HTML in 1996, led to web apps  Written device drivers, console apps, desktop apps, services, websites, and mobile apps  Worked as code monkey, dev team lead and manager, architect, and product lead  Currently at Balance Innovations working with web and mobile  Presentation available at:

Why Are We Here?  MVC == Model – View – Controller  Focus on ASP.NET with C#  “The Wise Man Learns from the Mistakes of Others, The Fool Has to Learn from His Own” – old proverb

Memory Lane  MVC 1 – 2009 .Net 3.5; VS 2008  MVC Pattern with Web Forms View Engine  Controller attributes like AcceptVerbs (Post, Get, etc)  Routing control  Html and Ajax helpers  MVC 2 – 2010 .Net 3.5, 4.0; VS 2008 & 2010  Strongly typed Html helpers  Asynchronous Controllers  Areas  ViewData  More helpers, utilities, enhancements

Memory Lane  MVC 3 – 2011 .Net 4.0; VS 2010  Razor View Engine and support for multiple View Engines  HTML 5 templates  ViewBag  Global Action Filters (OnActionExecuting, OnException, etc)  Unobtrusive JavaScript client side validation and Remote attribute  MVC 4 – 2012 .Net 4.0, 4.5; VS 2010, 2012  Web API  New Mobile project template  Bundling and Minifications  OAuth and OpenID support  Asynch Await  SignalR  Empty project template and NuGet integration in VS

Memory Lane  MVC 5 – 2013 .Net 4.5, 4.5.1, VS 2013  One ASP.NET and New Project options  New ASP.NET Identity and Authentication options  OWIN and Katana integration  More improvements and updates

In The Beginning…  Recommend using Empty  Consider One ASP.NET options  Try each template – each adds some libraries and objects

In the Beginning…  Web Forms, MVC, and Web API enable Change Authentication

Control Your Site  Remember the purpose of the Controller – KISS your actions  Consider the size and scope of the project  Create base controllers

Control Your Site

 MVC 5 adds new Add Controller provides many scaffolding options

Control Your Site  Authentication and Authorization strategy  Customize routes, use good parameter names  Respond to validation errors  Choose good return types  Know your MV* pattern and what type of Controller you need

Control Your Site

Show Me The Data  Data Model vs. View Model:  Data Model focuses on data persistence  View Model focuses on the View, client-side validation, and some formatting

Show Me The Data  Initialize properties, especially collections  Use concrete classes  Display properties  Keep logic requirement in code, increases reusability  Consider globalization and localization  View Model as properties on other View Models behave differently  Required Attribute does not work  Use Editor Template to cover field specific validation  Consider Remote Attribute to cover broader validation  Be mindful of the User Experience with the flow of validation  Not all validation can occur before the page reloads  Know your MV* pattern

Model Examples

Do You See What I See? - Laying The Groundwork  _Layout is important, be intentional with it  Consider using meta viewport to help your site on mobile devices  Add RenderSection for JavaScript and CSS  Keep it simple, use partials for changeable parts  Decide where to put you JavaScript

Do You See What I See? - Laying The Groundwork

Do You See What I See? – The Guts  Strongly type your views  Put all your properties in the View Model  Minimize code – keep logic and formatting code in code  Your properties should already be initialized and not null  Check counts and flags if there is a question about what to display  Create Helpers for small mixes of code and display  Consider RouteLink over ActionLink  Match View Models to each nested View, Editor Template, or Display Template  Nest carefully  Always pass the collection  Never pass nulls  Know your MV* pattern  Know what devices and screen resolutions you support  Mobile is not so much a question of “If?”, rather “First?”  Do not do client side browser name and version checks, rather do feature checks and server side framework checks (Request.Browser.IsMobileDevice)

Do You See What I See? – The Guts

Config Transforms  Web.Config vs database for configuration settings  Web.Config for infrastructure and rarely changing settings – server names, IP addresses, client name, database connection string  Database for system functionality and more often change – layout template, features on/off, how many items per page  Consider encrypting all or sensitive portions of.config files  Use Transforms to manage settings for different servers  Add: xdt:Transform="Replace" xdt:Locator="Match(name)“

Config Transforms

Bundling and Minification  Smaller files are always better  Group your CSS and JavaScript logically for most cases  StyleBundle("~/Content/css")  StyleBundle("~/Content/cssadmin")  ScriptBundle("~/bundle/scripts")  ScriptBundle("~/bundle/scriptsadmin")  May have some duplication because you cannot nest bundles  Add page specific and/or feature specific for other files  StyleBundle("~/Content/dateselect")  StyleBundle("~/Content/logon")  Use BundleTable.EnableOptimizations to force raw version in prod  Chrome Developer Tools, click “{ }” to un-minify

Remember The Mobile!  Do not have to be mobile first  Add a mobile View with _Layout.mobile.cshtml and Index.mobile.cshtml  Options to customize what is a mobile device  Use

Valuable One Liners  Pick your 3 rd parties wisely – use the Community, Luke  Down with magic strings  Use OWIN  Extension methods  Consider Dependency Injection  For public sites, strongly consider OAuth  SignalR or other Web Sockets  Update to MVC 5 or 6

Pimp Your Code – Optimize  Throw fewer, more intelligent exceptions  Why do you use var data type?  Be more chunky than chatty, but really be lean  Guess and test Async Await usage  Use AddRange to add multiple items to a collection  Use LINQ methods  Clean out local variables  StringBuilder is best when you do not know what you are concatenating  String.Join is ideal for collections  Name Views in action methods  Evaluate your loops

Thanks!    Presentation: