/******************************************************************************* * Copyright 2009-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may * not use this file except in compliance with the License. A copy of the * License is located at * * http://aws.amazon.com/apache2.0/ * * or in the "license" file accompanying this file. This file is * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the specific * language governing permissions and limitations under the License. *******************************************************************************/ using System; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using dotnetLexChatBot.Data; namespace dotnetLexChatBot { public class Startup { // public Startup(IWebHostEnvironment env) // { // var builder = new ConfigurationBuilder() // .SetBasePath(env.ContentRootPath) // .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) // .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) // .AddEnvironmentVariables(); // Configuration = builder.Build(); // } 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.AddOptions(); // Register the IConfiguration instance which MyOptions binds against. services.Configure(Configuration.GetSection("AWSConfiguration")); services.AddScoped(); // // Add Session Obj services.AddSession(options => { // Set a short timeout for easy testing. options.IdleTimeout = TimeSpan.FromSeconds(300); options.Cookie.HttpOnly = true; }); services.AddControllersWithViews(); } // 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.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSession(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=HelloChatBot}/{action=TestChat}/{id?}"); }); // app.UseMvc(routes => // { // routes.MapRoute( // name: "default", // template: "{controller=HelloChatBot}/{action=TestChat}/{id?}"); // }); } } }