Created
February 23, 2016 06:50
-
-
Save kwanann/7bced8e22fec229bd0be to your computer and use it in GitHub Desktop.
Sample startup.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Startup | |
{ | |
public Startup(IHostingEnvironment env, IApplicationEnvironment env2) | |
{ | |
} | |
public IConfigurationRoot Configuration { get; set; } | |
// This method gets called by the runtime. Use this method to add services to the container. | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
// Add framework services. | |
services.AddMvc(); | |
services.AddSingleton<ITestDependencyInjection, MyTestDependencyInjection>(); | |
} | |
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. | |
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) | |
{ | |
app.Use(async (ctx, next) => | |
{ | |
ITestDependencyInjection testdi = ctx.ApplicationServices.GetService<ITestDependencyInjection>(); | |
Console.WriteLine("App.use -0 before next: " + testdi.GetAndIncrementCounter()); | |
await next(); | |
Console.WriteLine("App.use - after next: " + testdi.GetAndIncrementCounter()); | |
}); | |
app.UseMvc(); | |
} | |
// Entry point for the application. | |
public static void Main(string[] args) => WebApplication.Run<Startup>(args); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment