devrock #01 what's new asp.net 5
TRANSCRIPT
![Page 1: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/1.jpg)
DevRock #01 Hello New Year 2015
ASP.NET 5
Chaowlert Chaisrichalermpol
Developer @ Jetabroad
![Page 2: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/2.jpg)
DevRock #01 Hello New Year 2015
JETABOARD
PRODUCTION
![Page 3: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/3.jpg)
DevRock #01 Hello New Year 2015
LEARN
![Page 4: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/4.jpg)
DevRock #01 Hello New Year 2015
ASP.NET 5 NEW PLATFORM
Unified MVC and WebAPI
New runtime, no more System.Web, or IIS, or Windows!
New project structure
New HTTP pipeline
New package management
Common IoC, and log interface + built-in IoC
New configuration & Options
New view features
New front-end workflow
![Page 5: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/5.jpg)
DevRock #01 Hello New Year 2015
OVERVIEW
![Page 6: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/6.jpg)
DevRock #01 Hello New Year 2015
LIBRARIES
.Net full .Net Core
WebForm 4.6 -
MVC 5MVC 6 (unified with WebAPI)
WebAPI 2
EF 6 EF 7 + support for non-relational
SignalR 2 SignalR 3
![Page 7: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/7.jpg)
DevRock #01 Hello New Year 2015
ASP.NET 5 MODULAR
MVC
Caching
Config
DataProtect
DI
FileLogging
Options
Razor
Routing
See more at https://github.com/aspnet/Home/wiki/Repo-List
![Page 8: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/8.jpg)
DevRock #01 Hello New Year 2015
ARCHITECTURE
New project type
Support new Core CLR
Self hosted
![Page 9: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/9.jpg)
DevRock #01 Hello New Year 2015
CORE CLR
![Page 10: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/10.jpg)
DevRock #01 Hello New Year 2015
CLR CORE CLR
CLR Core CLR
Install per machine Install per application
1 major version for all applications Run different version side by side
Runtime 200 MB Runtime 11 MB (Only what you need)
Host on Windows Host anywhere
Normal performance Fast startup
Lower memory usage (-35%)*
More request per seconds
Full backward compatibility Some backward compatibility
* http://james.newtonking.com/archive/2014/10/24/json-net-6-0-release-6-asp-net-coreclr-support-
memory-usage-optimizations
![Page 11: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/11.jpg)
DevRock #01 Hello New Year 2015
PROJECT STRUCTURE
![Page 12: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/12.jpg)
DevRock #01 Hello New Year 2015
PROJECT STUCTURE
No more global.asax & web.config
global.json
Startup.cs
wwwroot
project.json
Files in project always include by default
![Page 13: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/13.jpg)
DevRock #01 Hello New Year 2015
HTTP PIPELINE
![Page 14: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/14.jpg)
DevRock #01 Hello New Year 2015
HTTP PIPELINE
Lean & fast
app.Run()
app.Use…
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory){
app.UseErrorHandler("/Home/Error");app.UseStaticFiles();app.UseIdentity();app.UseMvc(routes => ...)
}
![Page 15: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/15.jpg)
DevRock #01 Hello New Year 2015
CUSTOM
public class SampleMiddleware {private readonly RequestDelegate next;public SampleMiddleware(RequestDelegate next) {
this.next = next;}public async Task Invoke(HttpContext context) {
await this.next.Invoke(context);}
}
app.UseMiddleware<SampleMiddleware>();
![Page 16: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/16.jpg)
DevRock #01 Hello New Year 2015
MVC
public void ConfigureServices(IServiceCollection services){
service.AddMvc();}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory){
app.UseMvc(routes => ...)}
![Page 17: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/17.jpg)
DevRock #01 Hello New Year 2015
PACKAGEMANAGEMENT
![Page 18: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/18.jpg)
DevRock #01 Hello New Year 2015
PACKAGE MANAGEMENT
Manage packages in project.json
No more Assembly references
Reference by NuGet
kpm
Packages are cached
![Page 19: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/19.jpg)
DevRock #01 Hello New Year 2015
LOG & IOC
![Page 20: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/20.jpg)
DevRock #01 Hello New Year 2015
LOG IOC
ILogger
Console
NLog
Serilog
Custom
IServiceProvider
Built-in
Autofac
Ninject
StructureMap
Unity
Windsor
Custom
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory){
loggerfactory.AddNLog(new NLog.LogFactory());}
public IServiceProvider ConfigureServices(IServiceCollection services){
...var builder = new ContainerBuilder();builder.Populate(services);return builder.Build().Resolve<IServiceProvider>();
}
![Page 21: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/21.jpg)
DevRock #01 Hello New Year 2015
IOC
services.AddSingleton
services.AddScoped
services.AddTransient
services.AddInstance
public void ConfigureServices(IServiceCollection services){
services.AddScoped<ICalculator, Calculator>();}
![Page 22: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/22.jpg)
DevRock #01 Hello New Year 2015
CONFIGURATION & OPTIONS
![Page 23: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/23.jpg)
DevRock #01 Hello New Year 2015
CONFIGURATION
no more web.config
Config from multiple sources
Structure is hierarchy
Configuration source
config.AddJsonFile
config.AddXmlFile
config.AddIniFile
config.AddEnvironmentVariable
config.AddCommandLine
Get config value
config.Get
IConfiguration config = new Configuration().AddJsonFile("config.json").AddEnvironmentVariable();
config.Get("path1:path2");
![Page 24: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/24.jpg)
DevRock #01 Hello New Year 2015
OPTIONS
Read from config is old school
Inject config as POCO
service.Configure<T>
IOptions<T>
public void ConfigureServices(IServiceCollection services){
services.AddOptions();services.Configure<MyAppOptions>(Config.GetSubKey("MyApp"));
}
![Page 25: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/25.jpg)
DevRock #01 Hello New Year 2015
NEW
VIEW FEATURES
![Page 26: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/26.jpg)
DevRock #01 Hello New Year 2015
VIEWCOMPONENT
Next step of PartialView
Behave like Controller
Razor views are located in
/Views/{controller}/Components/{component}/{view_name}.cshtml
/Views/Shared/Components/{component}/{view_name}.cshtml
public class MyViewComponent : ViewComponent {public IViewComponentResult Invoke(param...) {
return View();}
}
![Page 27: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/27.jpg)
DevRock #01 Hello New Year 2015
VIEW INJECTION
@{ViewBag.Title = "Home Page";
}
<div>Value is @calc.Add(1, 1)</div>
@inject ICalculator calc
![Page 28: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/28.jpg)
DevRock #01 Hello New Year 2015
TAGHELPERS
@HTML.Label("FirstName", "First Name:", new { @class = "caption" }) is unreadable
<label class="caption" for="FirstName">First Name:</label>is better
public class DateTimePickerTagHelper : TagHelper {public override void Process(TagHelperContext context, TagHelperOutput output) {}
}
@addtaghelper "Assembly.Name"
<datetimepicker id="myDate" value="@Model.StartDate"></datetimepicker>
![Page 29: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/29.jpg)
DevRock #01 Hello New Year 2015
FRON-END FRAMEWORK
![Page 30: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/30.jpg)
DevRock #01 Hello New Year 2015
BOWER
No more js library from NuGet
20,000+ packages
No more js collision
You decide what should include in project
![Page 31: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/31.jpg)
DevRock #01 Hello New Year 2015
GRUNT & GULP
No more ASP.net bundle
4,000+ tasks
Bind with Visual Studio
Before Build
After Build
Clean
Open
![Page 32: DevRock #01 What's new ASP.net 5](https://reader034.vdocument.in/reader034/viewer/2022042615/55a59f9c1a28aba0018b46fa/html5/thumbnails/32.jpg)
DevRock #01 Hello New Year 2015
Q A