11/6/2016 - 9:59 AM

ASP.NET Core notes.

ASP.NET Core notes.

ASP.NET Core Notes:

  • Project file structure is the same as the file structure on object browser.
  • If you change a file when core application is running on vs, it watches the file automatically.

In StartUp class:

  • Configuration file can be constructed on constructor.
IConfiguration Configuration {get; set;}

// Default env variable can be seen from project file 
// => right click to properties => debug env variables in VS,
// in or Properties/launchSettings.json
public Startup(IHostingEnvironment env){
    var builder = new ConfigurationBuilder()
    Configuration = builder.Build();    
  • ConfigureServices method is where DI issues are going to be handled.

  • services.AddSingleton<IGreeter, Greeter>();

  • services.AddSingleton(Instance); ==> Equals to .AsImplementedInterfaces() of Autofac.

  • AddTransient ==> News when method or class needs

  • AddScope ==> Http request scope

  • Configure method is for configuring the HTTP request pipeline, and middlewares.

  • app.UseTheMiddleWare

  • ex: app.UseWelcomePage('/welcome');

  • Middleware registration order is important.

  • Middlewares are generally a package (Find them on NuGet)