Exemple #1
0
        public void Configure(IApplicationBuilder app)
        {
            // Setup configuration sources
            var configuration = new Configuration();

            configuration.AddJsonFile("config.json");
            configuration.AddEnvironmentVariables();

            // Set up application services
            app.UseServices(services =>
            {
                // Add EF services to the services container and configure DbContext
                services.ConfigureDataContext(configuration);

                // Register MyShuttle dependencies
                services.ConfigureDependencies();


                //Add Identity services to the services container
                services.AddDefaultIdentity <MyShuttleContext, ApplicationUser, IdentityRole>(configuration);
                services.ConfigureCookieAuthentication(options =>
                {
                    options.LoginPath = new Microsoft.AspNet.Http.PathString("/Carrier/Login");
                });


                // Add MVC services to the services container
                services.AddMvc();

                services
                .AddSignalR(options =>
                {
                    options.Hubs.EnableDetailedErrors = true;
                });
            });

            // Enable Browser Link support
            app.UseBrowserLink();

            /* Error page middleware displays a nice formatted HTML page for any unhandled exceptions in the request pipeline.
             * Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
             */
            app.UseErrorPage(ErrorPageOptions.ShowAll);

            // Add static files to the request pipeline
            app.UseStaticFiles();

            app.ConfigureSecurity();

            //Configure SignalR
            app.UseSignalR();

            // Add cookie-based authentication to the request pipeline

            // Add MVC to the request pipeline
            app.ConfigureRoutes();

            MyShuttleDataInitializer.InitializeDatabaseAsync(app.ApplicationServices).Wait();
        }
        public static void Main(string[] args)
        {
            var host = BuildWebHost(args);

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;

                try
                {
                    MyShuttleDataInitializer.InitializeDatabaseAsync(services).Wait();
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred seeding the DB.");
                }
            }
            host.Run();
        }
        // Configure is called after ConfigureServices is called.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            // Add static files to the request pipeline
            app.UseStaticFiles();

            // Add cookie-based authentication to the request pipeline
            app.UseIdentity();

            /* Error page middleware displays a nice formatted HTML page for any unhandled exceptions in the request pipeline.
             * Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
             */
            app.UseErrorPage(ErrorPageOptions.ShowAll);

            app.ConfigureSecurity();

            //Configure SignalR
            app.UseSignalR();

            // Add MVC to the request pipeline
            app.ConfigureRoutes();

            MyShuttleDataInitializer.InitializeDatabaseAsync(app.ApplicationServices).Wait();
        }
Exemple #4
0
 public void Configure(IApplicationBuilder app)
 {
     app.ConfigureRoutes();
     MyShuttleDataInitializer.InitializeDatabaseAsync(app.ApplicationServices).Wait();
 }