ZZ Bl ack Coffee #8 Hello ASP.NET MVC 4 Chalermpon Areepong Nine (นนน)
May 10, 2015
ZZ Black Coffee #8 Hello ASP.NET MVC 4Chalermpon AreepongNine (นาย)
About me
0 Chalermpon Areepong0 Microsoft MVP Thailand (ASP.NET)
0 Work for ICBC THAI0 Blog http://nine69.wordpress.com0 User Group https://
www.facebook.com/groups/MVCTHAIDEV
AGENDA
0 Enhancement to default project template0 New Razor 2.00 Bundling and Minification0 ASP.NET WEB APIs0 Enhanced support for asynchronous methods0 New Mobile Support
Enhancements to Default Project Templates
0 Design for adaptive rendering to look good in both desktop browsers and mobile browsers without any customization.
Demo
0 Show new default project template
New Razor 2.0
0 Razor now supports conditional attributes. In an HTML element
<input type="checkbox“ name="check1" value="check1" checked="@checked1" />
0 Support path “~/” for all HTML attributes
Demo
0 Razor 2
Bundling and Minifacation
0 Reduce size of script and css file (remove whitespace)0 New App_Start Folder
0 BundleConfig.cs0 BundleConfig. RegisterBundles()
bundles.Add(new ScriptBundle("~/bundles/jquery").Include("~/Scripts/jquery-1.*"));
bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));*changes from Beta
0 Call in [email protected]("~/bundles/jquery")@Styles.Render("~/Content/themes/base/css", "~/Content/css")
Demo
0 Bundling and Minifacation
ASP.NET WEB APIs
0 Change name from WCF Web API 0 Easy to build HTTP services0 Support Browsers and Mobile devices0 Build RESTful applications on the .NET Framework
ASP.NET WEB APIs
Requestjson, xml, form
Device App
Responsejson, xml
Web App
Others HTTP Request
HTTP get, post, etc.
ASP.NETWEB API
ASP.NET WEB APIs
0 Modern HTTP programming model: Directly access and manipulate HTTP requests and responses in your Web APIs using a new, strongly typed HTTP object model.
0 Full support for routes: 0 Content negotiation: support for XML, JSON, and Form URL-encoded
formats and custom format.0 Model binding and validation: like controller base0 Filters: support filter such as [Authorize]attribute.0 Query composition: Use the [Queryable] filter attribute on an action that
returns IQueryable to enable support for querying your web API via the OData query conventions.
0 Improved Testability: use HttpRequestMessage and HttpResponseMessage to create a unit test project
ASP.NET WEB APIs0 Code-based configuration: ASP.NET Web API configuration is accomplished
solely through code, leaving your config files clean. Use the provide service locator pattern to configure extensibility points.
0 Improved support for Inversion of Control (IoC) containers: support dependency resolver abstraction
0 Self-host: Web APIs can be hosted in your own process in addition to IIS while still using the full power of routes and other features of Web API.
0 Create custom help and test pages: using the new IApiExplorer service to get a complete runtime description of your web APIs.
0 Monitoring and diagnostics: System.Diagnostics, ETW and third party logging frameworks.
0 Link generation: Use the ASP.NET Web API UrlHelper to generate links to related resources in the same application.
0 Web API project template: new project template 0 Scaffolding: by Add Controller dialog to quickly.
Demo
0 Basic Web API0 SelfHost ( AspNetWebApi.Selfhost )0 MVC Chat
Enhanced support for asynchronous methods
0 Support Async in .NET Framework 4.50 TASK<T>
0 New “async”, “await” keyword0 Reduce async code
public async Task<ActionResult> GetSocialDatas(string username){ var facebook = new FBService(); var twitter = new TwitterService(); return View(“SocialData", new SocialDataViewModel { FBWalls = await facebook.GetWallsAsync(string username), TwTimeLines = await twitter.GetTimeLineAsync(string username) });}
http://wiki.jvmlangsummit.com/images/3/33/Async_in_.NET.pdf
Demo
0 MVC New Async Operation
New Mobile Support
0 Mobile Project Template0 jQuery mobile script0 Mobile Theme
New Mobile Support
0 ViewSwitcher0 Detect device0 Switch view to mobile layout0 Can create layout for device by specification
Demo
0 New Mobile Support
End