Beispiel #1
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        /// </summary>
        /// <param name="app"></param>
        /// <param name="env"></param>
        /// <param name="loggerFactory"></param>
        /// <param name="options"></param>
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, Microsoft.Extensions.Options.IOptions <ViewBookingOptions> options)
        {
            Log.Logger = new LoggerConfiguration().ReadFrom.Configuration(Configuration).CreateLogger();
            loggerFactory.AddSerilog();
            var config = options.Value;

            try
            {
                //to log errors thrown by Startup() and ConfigureServices()
                if (StartupErrorHandler.WriteExceptionsToResponse(app, _exceptions, loggerFactory))
                {
                    return;
                }
                ErrorHandlingSetup(app, env);
                app.UseStaticFiles();
                app.UsePathBase(config.ApplicationRoot);
                app.UseStatusCodePages();
#if DEBUG
                app.UseCors("Default");
#endif
                app.UseMvc(routes =>
                {
                    routes.MapRoute(
                        name: "default",
                        template: "{controller=Traveller}/{action=Get}/{id?}");
                });
                //app.UseMvcWithDefaultRoute();

                AssemblyInformation.SetMainAssembly(Assembly.GetExecutingAssembly());
            }
            catch (Exception ex)
            {
                StartupErrorHandler.WriteExceptionToResponse(app, ex, loggerFactory);
            }
        }