ASP.NET and Visual Studio 2012

download report

Transcript ASP.NET and Visual Studio 2012

ASP.NET and Visual Studio 2012

Robert Boedigheimer

About Me

• Web developer since 1995 • Columnist for aspalliance.com

• Pluralsight Author • 3 rd Degree Black Belt, Tae Kwon Do • ASP.NET MVP • http://aspadvice.com/blogs/robertb/ • [email protected]

• @boedie www.devreach.com

Visual Studio 2012

• Project and solution “round tripping” – VS 2010 SP1 <-> VS 2012 – Can use new editor features – Breaks if use .NET 4.5 features • Quick Launch • Solution explorer – Drill into classes and methods – Image thumbnails www.devreach.com

Visual Studio 2012 (cont)

• Search everywhere • Preview Tab • Browser Chooser • Turn off all caps – HKEY_CURRENT_USER\Software\Micros oft\VisualStudio\11.0\General\SuppressUp percaseConversion – REG_DWORD 1 www.devreach.com

Editor Improvements

• Editor Parity (HTML, CSS, JavaScript) – Brace matching – Regions – Outlining – Commenting – Formatting www.devreach.com

HTML Editor Improvements

• Matching tag renaming • Event handler setup (source view) • Smart Tasks (source view) • HTML 5 – IntelliSense for tags – Snippets – New doctype, missing some simplifications • Attribute Code IntelliSense www.devreach.com

JavaScript Editor Improvements

• • ECMAScript 5 full support • IntelliSense improvements

Implicit References

Tools -> Options -> Text Editor -> JavaScript -> IntelliSense -> References

• Go to definition • Uses IE 9 JavaScript engine www.devreach.com

CSS Editor Improvements

• CSS 3 • CSS Snippets • Vendor specific prefixes • Improved color picker (with opacity) • Hierarchical Indentation • Knows common “hacks” • Comment/Uncomment www.devreach.com

Page Inspector

Install with Web Platform Installer

• Browser diagnostics in Visual Studio – Trace from web page to source code – View position in DOM – Trace CSS properties for element to the rule www.devreach.com

Request Validation

• Previous ASP.NET approach – Validation by default – Turn off at site or page level •

Miscellaneous

• Publish profiles – Build configurations included in dialog (debug, release) • IIS Express • Performance – Interning – symbolic links to single shared assembly, aspnet_intern.exe, runs in .NET 4 – JIT compiles across processor cores (on by default) – GC tuning www.devreach.com

Fiddler

• Tracing tool specifically for HTTP • Shows complete request and response (not packets) • Can save archive of session • Transfer Timeline • http://tinyurl.com/3drk5t www.devreach.com

Performance Rules

• For most web sites, only 10-20% of response time is waiting for the HTML document to be generated and downloaded – Not optimizing code!

• Make fewer HTTP requests • Send as little as possible • Send it as infrequently as possible www.devreach.com

Bundling and Minification

• •

Make fewer HTTP requests Send as little as possible

• Minimize CSS and JavaScript files – Remove whitespace, comments, excessive semicolons, etc • Bundle/combine to reduce number of HTTP requests • Previous method – AjaxMinifier, MSBuild – http://aspalliance.com/1992 – Home page was

46% faster

!!

www.devreach.com

ASP.NET Bundling and Minification

• Runtime (but results cached in memory) • Default order – Common libraries first (jQuery, etc) – Alphabetical • Multiple bundles are ok • API – Customize ordering of files – Customize transforms (CoffeeScript, LESS, etc) www.devreach.com

Content Expirations

• Client asks “if-modified-since” • Small content files it is just as expensive to see if modified as to receive content • Leverage user’s browser cache • Setup expiration times for content folders • Avoid requests for files that seldom change (.js, .css, images, etc) • Rename the file if need to override browser caching www.devreach.com

ASP.NET Bundling and Minification (2)

• Add a hash value to bundle URLs – Take advantage of caches for repeat visitors – Change the URL to avoid cache when change files using ResolveBundleUrl( ) www.devreach.com

Asynchronous Improvements

• Asynchronous HTTP Modules and Handlers • await

wait asynchronously for some other code to complete • async – used to mark method as asynchronous task based method www.devreach.com

IIS 8

• Web Sockets – Bi-directional sockets between web browser and server – Avoid polling, long polling, Comet – HTML 5 (IE 10, Firefox 6+, Chrome 14+) – System.Web.WebSockets

• Performance improvements – Reduction in startup time and memory footprint www.devreach.com

Web Forms

• Drag user controls in source view • Extract user controls from web pages • DataBinding with HTML Encoding – <%#

:

… > • Strongly Typed Data Controls – ItemType www.devreach.com

HTML 5

• TextBox supports HTML 5 types – search – email – url – tel – range – slider – number – spinner – date, datetime, time, month, week – color • Not yet aware of new input attributes (placeholder, autofocus, required, pattern, etc) www.devreach.com

Unobtrusive Validation

• Previously had large amount of JavaScript injected into HTML when used validators • JavaScript moved to external script • Uses “data-” attributes – Control attributes so accessible on client, such as

data-val display=“Dynamic“

for

Display=“Dynamic”

• Not used by default, opt in via web.config

– ValidationSettings:UnobtrusiveValidationMode • PM> Install-Package Microsoft.ScriptManager.jQuery

www.devreach.com

Model Binding

• Model binding originally introduced with ASP.NET MVC, while integrating with existing Web Forms server controls • Previously used DataSource controls or ObjectDataSource – Developers often want more control • “Code focused approach to data-binding” – Create methods for data access – Server controls will use methods at appropriate times www.devreach.com

Model Binding (2)

• SelectMethod, UpdateMethod, DeleteMethod • Filtering via “Value Provider Attributes” – querystring, cookies, form values, controls, viewstate, session, or profile • Model Validation – Create a new partial class – System.ComponentModel.DataAnnotations

– ShowModelStateErrors – ModelState.IsValid

www.devreach.com

Web Essentials 2012

• Mads Kristensen (Microsoft) • http://tinyurl.com/cyk825y • Add vendor prefixes • Show browser support • Data URI conversion (fallback support) • Insert hacks for specific IE versions • Colors conversions • CoffeeScript and LESS support • JavaScript regions www.devreach.com

Resources

• http://www.asp.net/vnext • Scott Guthrie’s ASP.NET 4.5 Blog Series – http://tinyurl.com/3sdqwb2 • Visual Studio 11 Developer Preview Training Kit – http://tinyurl.com/3fwwzxb www.devreach.com

Thank you!

@boedie blogs.aspadvice.com/robertb [email protected]

Robert Boedigheimer