// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.BotBuilderSamples.Bots; using Microsoft.BotBuilderSamples.Dialog; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); // Create the bot services(QnA) as a singleton. services.AddSingleton(); // Create the storage we'll be using for User and Conversation state. (Memory is great for testing purposes.) services.AddSingleton(); // Create the User state. (Used in this bot's Dialog implementation.) services.AddSingleton(); // Create the Conversation state. (Used by the Dialog system itself.) services.AddSingleton(); // The Dialog that will be run by the bot. services.AddSingleton(); // Create the bot as a transient. In this case the ASP Controller is expecting an IBot. services.AddTransient>(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseDefaultFiles() .UseStaticFiles() .UseRouting() .UseAuthorization() .UseEndpoints(endpoints => { endpoints.MapControllers(); }); // app.UseHttpsRedirection(); } } }