Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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.

Jay Harris

June 11, 2016
Tweet

More Decks by Jay Harris

Other Decks in Technology

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. ./MyWebProject/ ├── wwwroot ├ Program.cs ├ project.json └ Startup.cs ./OldMvcProject/

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

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

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

    ├── Controllers ├── Content ├── Scripts ├── Views ├ OldMvcProject.csproj ├ Global.asax ├ Global.asax.cs ├ packages.config └ web.config ∠
  6. ./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 ∠
  7. ./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 ∠
  8. ./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 ∠
  9. 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 ∠
  10. ./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 ∠
  11. ./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 ∠
  12. { "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-*" } }
  13. { "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", } }
  14. public class Program { public static void Main(string[] args) {

    var host = new WebHostBuilder() .UseKestrel() .UseIISIntegration() .UseStartup<Startup>() .Build(); host.Run(); } }
  15. public class Program { public static void Main(string[] args) {

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

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

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

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

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

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

    get; set; } public HomeController(IWidgetService widgetService) { Widgets = widgetService; } }
  22. { "Twilio": { "Account": "abcdef0123456789", "AuthToken": "fedcba9876543210" }, "Data": {

    "DefaultConnection": { "Connectionstring": "Server=.;Database=MyDatabase;" } } }
  23. 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"); }
  24. 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"); }
  25. 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"); }
  26. 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
  27.  dotnet run ' Hosting environment: Production Now listening on:

    http://localhost:5000 Application started. Press Ctrl+C to shut down.
  28. @ j a y h a r r i s

    # a s p N e t Re b o o t [email protected]