Rebooting the ASP.NET Franchise

Rebooting the ASP.NET Franchise

Are you an ASP.NET developer that is tired of the baggage and cruft within the framework? Do you wish you could use OS X for developing ASP.NET apps? Are you new to ASP.NET, but are adverse to installing Windows and Visual Studio? Everything has changed: ASP.NET isn’t just for Visual Studio, anymore. Learn how ASP.NET has broken free from Windows and has turned into a fresh, cross-platform, OS-agnostic framework. Develop ASP.NET applications on your OS, with your editor, in your way. No more compromises, no VMs, no workarounds. Grab some popcorn an experience the reboot of the ASP.NET Franchise.

1318668b99b2d5a3900f3f7758763a69?s=128

Jay Harris

June 11, 2016
Tweet

Transcript

  1. #aspNetReboot R E B O O T I N G

    T H E A S P. N E T F RA N C H I S E @ j a y h a r r i s
  2. asp.net core

  3. 1.0.0-*

  4. aspnet/home MIT license ! 

  5. breaking change

  6. folder structure

  7. ./MyWebProject/ ├── wwwroot ├ Program.cs ├ project.json └ Startup.cs

  8. ./MyWebProject/ ├── wwwroot ├ Program.cs ├ project.json └ Startup.cs ./OldMvcProject/

    ├── Controllers ├── Content ├── Scripts ├── Views ├ OldMvcProject.csproj ├ Global.asax ├ Global.asax.cs ├ packages.config └ web.config ∠
  9. ./MyWebProject/ ├── wwwroot ├ Program.cs ├ project.json └ Startup.cs ./OldMvcProject/

    ├── Controllers ├── Content ├── Scripts ├── Views ├ OldMvcProject.csproj ├ Global.asax ├ Global.asax.cs ├ packages.config └ web.config ∠
  10. ./MyWebProject/ ├── wwwroot ├ Program.cs ├ project.json └ Startup.cs ./OldMvcProject/

    ├── Controllers ├── Content ├── Scripts ├── Views ├ OldMvcProject.csproj ├ Global.asax ├ Global.asax.cs ├ packages.config └ web.config ∠
  11. ./MyWebProject/ ├── wwwroot ├ Program.cs ├ project.json └ Startup.cs ./OldMvcProject/

    ├── Controllers ├── Content ├── Scripts ├── Views ├ OldMvcProject.csproj ├ Global.asax ├ Global.asax.cs ├ packages.config └ web.config ∠
  12. ./MyWebProject/ ├── wwwroot ├ config.json ├ Program.cs ├ project.json └

    Startup.cs ./OldMvcProject/ ├── Controllers ├── Content ├── Scripts ├── Views ├ OldMvcProject.csproj ├ Global.asax ├ Global.asax.cs ├ packages.config └ web.config ∠
  13. ./MyWebProject/ ├── Controllers ├── Views ├── wwwroot ├ config.json ├

    Program.cs ├ project.json └ Startup.cs ./OldMvcProject/ ├── Controllers ├── Content ├── Scripts ├── Views ├ OldMvcProject.csproj ├ Global.asax ├ Global.asax.cs ├ packages.config └ web.config ∠
  14. ./MyWebProject/ ├── Controllers ├── Views ├── wwwroot │ ├── Content

    │ └── Scripts ├ config.json ├ Program.cs ├ project.json └ Startup.cs ./OldMvcProject/ ├── Controllers ├── Content ├── Scripts ├── Views ├ OldMvcProject.csproj ├ Global.asax ├ Global.asax.cs ├ packages.config └ web.config ∠
  15. Serve /wwwroot/**/*.* Serve /**/*.* except: .ad .adprototype .asax .ascx .browser

    .cd .compiled .config .cs .csproj .dd .dgdsm .dsprototype .exclude .java .jsl .ldb .ldd .lddprototype .ldf .licx .lsad .lsaprototype .master .mdb .mdf .msgx .refresh .resources .resx .rules .sd .sdm .sdmDocument .sitemap .skin .ssdgm .ssmap .vb .vbproj .vjsproj .vsdisco .webinfo ∠
  16. ./MyWebProject/ ├── Controllers ├── Views ├── wwwroot │ ├── Content

    │ └── Scripts ├ config.json ├ Program.cs ├ project.json └ Startup.cs ./MyMvcProject/ ├── Controllers ├── Content ├── Scripts ├── Views ├ MyMvcProject.csproj ├ Global.asax ├ Global.asax.cs ├ packages.config └ web.config ∠
  17. ./MyWebProject/ ├── Controllers ├── Views ├── wwwroot │ ├── Content

    │ └── Scripts ├ config.json ├ Program.cs ├ project.json └ Startup.cs ./MyMvcProject/ ├── Controllers ├── Content ├── Scripts ├── Views ├ MyMvcProject.csproj ├ Global.asax ├ Global.asax.cs ├ packages.config └ web.config ∠
  18. code changes

  19. MyWebProject ├── Controllers ├── Views ├── wwwroot ├ config.json ├

    Program.cs ├ project.json └ Startup.cs
  20. MyWebProject ├── Controllers ├── Views ├── wwwroot ├ config.json ├

    Program.cs ├ project.json └ Startup.cs
  21. { "authors": ["Jay Harris"], "dependencies": { }, "scripts": { },

    "frameworks": { "netcoreapp1.0": { } } }
  22. { "version": "1.0.0", "authors": ["Jay Harris"], "description": "This is my

    new web project" }
  23. { "dependencies": { "Microsoft.NETCore.App": { "type": "platform", "version": "1.0.0-*" }

    "Microsoft.AspNetCore.Mvc": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.AspNetCore.StaticFiles": "1.0.0-*" } }
  24. { "scripts": { "postrestore": [ "npm install" ], "prepare": [

    "grunt bower:install" ] } }
  25. { "scripts": { "prerestore": "echo runs before restoring nuget packages",

    "postrestore": "echo runs after restoring nuget packages", "prepare": "echo runs after post restore / before prepack" "prepack": "echo runs before nuget packaging", "postpack": "echo runs after nuget packaging", "prebuild": "echo runs before building project", "postbuild": "echo runs after building project", } }
  26. "frameworks": { "netcoreapp1.0": { "imports": [ "dotnet5.4", "dnxcore50", "portable-net45+win8" ]

    } }
  27. MyWebProject ├── Controllers ├── Views ├── wwwroot ├ config.json ├

    Program.cs ├ project.json └ Startup.cs
  28. public class Program { public static void Main(string[] args) {

    var host = new WebHostBuilder() .UseKestrel() .UseIISIntegration() .UseStartup<Startup>() .Build(); host.Run(); } }
  29. MyWebProject ├── Controllers ├── Views ├── wwwroot ├ config.json ├

    Program.cs ├ project.json └ Startup.cs
  30. public class Program { public static void Main(string[] args) {

    var host = new WebHostBuilder() .UseKestrel() .UseIISIntegration() .UseStartup<Startup>() .Build(); host.Run(); } }
  31. public class Startup { public void Configure(IApplicationBuilder app, IHostingEnvironment env,

    ILoggerFactory loggerFactory) { } public void ConfigureServices(IServiceCollection services) { } }
  32. public class Startup { public void Configure(IApplicationBuilder app, IHostingEnvironment env,

    ILoggerFactory loggerFactory) { app.UseFileServer(); app.UseSignalR(); } }
  33. public class Startup { public void Configure(IApplicationBuilder app, IHostingEnvironment env,

    ILoggerFactory loggerFactory) { app.UseFileServer(); app.UseSignalR(); app.UseMvc(); } }
  34. public class Startup { public void ConfigureServices(IServiceCollection services) { services.AddSignalR();

    } }
  35. public class Startup { public void ConfigureServices(IServiceCollection services) { services.AddSignalR();

    services.AddMvc(); } }
  36. public class Startup { public void ConfigureServices(IServiceCollection services) { services.AddSignalR();

    services.AddMvc(); services.AddTransient<WidgetService>(); services.AddSingleton<GadgetService>(); } }
  37. public class Startup { public void ConfigureServices(IServiceCollection services) { services.AddSignalR();

    services.AddMvc(); services.AddTransient<IWidgetService, WidgetService>(); services.AddSingleton<IGadgetService, GadgetService>(); } }
  38. public class HomeController : Controller { public IWidgetService Widgets {

    get; set; } public HomeController(IWidgetService widgetService) { Widgets = widgetService; } }
  39. public class HomeController : Controller { [Activate] public IWidgetService Widgets

    { get; set; } }
  40. MyWebProject ├── Controllers ├── Views ├── wwwroot ├ Program.cs ├

    config.json ├ project.json └ Startup.cs
  41. { "Twilio": { "Account": "abcdef0123456789", "AuthToken": "fedcba9876543210" }, "Data": {

    "DefaultConnection": { "Connectionstring": "Server=.;Database=MyDatabase;" } } }
  42. { "dependencies": { "Microsoft.AspNetCore.Mvc": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.AspNetCore.StaticFiles": "1.0.0-*", "Microsoft.Extensions.Configuration.Json":

    "1.0.0-*" } }
  43. { "dependencies": { "Microsoft.AspNetCore.Mvc": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.AspNetCore.StaticFiles": "1.0.0-*", "Microsoft.Extensions.Configuration.Json":

    "1.0.0-*" "Microsoft.Extensions.Configuration.Xml": "1.0.0-*" "Microsoft.Extensions.Configuration.Ini": "1.0.0-*" } }
  44. public class Startup { public void Startup() { Configuration =

    new ConfigurationBuilder() .AddJsonFile("Config.json") .Build(); } public IConfigurationRoot Configuration { get; set; } public void Configure(IApplicationBuilder app) { var twilioAccount = Configuration.Get("Twilio:Account"); }
  45. public class Startup { public void Startup() { Configuration =

    new ConfigurationBuilder() .AddJsonFile("config.json") .Build(); } public IConfigurationRoot Configuration { get; set; } public void Configure(IApplicationBuilder app) { var twilioAccount = Configuration.Get("Twilio:Account"); }
  46. public class Startup { public void Startup() { Configuration =

    new ConfigurationBuilder() .AddJsonFile("config.json") .Build(); } public IConfigurationRoot Configuration { get; set; } public void Configure(IApplicationBuilder app) { var twilioAccount = Configuration.Get("Twilio:Account"); }
  47. tools & platform

  48. None
  49. None
  50. None
  51. ┌────┼────┐

  52. └────┼────┘

  53. None
  54. None
  55. None
  56. None
  57. # ? %

  58. ┐ │ ┼ │ ┘

  59. # ? %

  60. ┐ │ ┼ │ ┘ ┌ │ ┼ │ └

  61. getting started

  62. & dotnet/core microsoft.com/net/core MIT license ! 

  63. dotnet '

  64. dotnet new '

  65. Created new C# project in... ' dotnet new '

  66. ' yeoman/yo npm install -g yo BSD license ! 

  67. npm install -g generator-aspnet '

  68. yo aspnet '

  69. ./MyWebProject/ ├── wwwroot ├ Program.cs ├ project.json └ Startup.cs

  70. .NET CLI

  71. dotnet restore '

  72. Microsoft.AspNetCore.Mvc 1.0.0 Microsoft.AspNetCore.Mvc.Razor 1.0.0 Microsoft.AspNetCore.Mvc.Cors 1.0.0 Microsoft.AspNetCore.Mvc.Core 1.0.0 dotnet restore

    ' '
  73. Microsoft.AspNetCore.Mvc 1.0.0 Microsoft.AspNetCore.Mvc.Razor 1.0.0 Microsoft.AspNetCore.Mvc.Cors 1.0.0 Microsoft.AspNetCore.Mvc.Core 1.0.0 nuget install

    Microsoft.AspNetCore.Mvc ' '
  74. dotnet new dotnet restore dotnet build dotnet run dotnet pack

    dotnet publish dotnet test ' # initialize a project # restore NuGet packages # compile the project # compile and execute # bundle NuGet package # publish application # run the project unit tests
  75.  ) dotnet run ' dotnet run '

  76.  dotnet run ' Hosting environment: Production Now listening on:

    http://localhost:5000 Application started. Press Ctrl+C to shut down.
  77. workflow

  78. workflow

  79. workflow

  80. workflow

  81. workflow

  82. OmniSharp

  83. & omnisharp omnisharp.net MIT license ! 

  84. None
  85. Task Runner Exp.

  86. & Visual Studio 2013: bit.ly/vs-trx MS Prerelease license 

  87. Packaged with Visual Studio 2015

  88. None
  89. learn more ! aspnet/home & asp.net * live.asp.net

  90. discussion ! aspnet/home + jabbr.net/#/rooms/AspNetCore

  91. sample code ! aspnet/musicstore ! aspnet/bugtracker

  92. install dotnetcore N E X T S T E P

    S
  93. make awesome

  94. @ j a y h a r r i s

    # a s p N e t Re b o o t jay@aranasoft.com