コード例 #1
0
        // 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)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
                // When you run the app and don't supply any URL segments, it defaults to the "Home" controller and the "Index" method specified above.

                // The Welcome (in HelloWorldController) method contains a parameter "id" that matched the URL template in the MapRoute method. The trailing ? (in id?) indicates the id parameter is optional.
            });
            DBinitialize.EnsureCreated(app.ApplicationServices);
            SeedData.Initialize(app.ApplicationServices);
        }
コード例 #2
0
        // 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)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Code}/{action=Index}/{id?}");
            });

            DBinitialize.EnsureCreated(app.ApplicationServices);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: shawndur/dotnet-test
        public static void Main(string[] args)
        {
            var host = BuildWebHost(args);

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;
                DBinitialize.EnsureCreated(services);
                SeedData.Initialize(services);
            }
            host.Run();
        }
コード例 #4
0
ファイル: Startup.cs プロジェクト: inkton/sample.wppod
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UseSwagger();

            app.UseSwaggerUI(options =>
            {
                options.SwaggerEndpoint("v1/swagger.json", "WP Pod API V1");
            });

            app.UseMvc();

            DBinitialize.EnsureCreated(app.ApplicationServices);
            DBinitialize.EnsureSeeded(app.ApplicationServices);
        }
コード例 #5
0
        // This method gets called by the runtime.
        // Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app)
        {
            app.UseAuthentication();
            app.UseSwagger();

            app.UseSwaggerUI(options => {
                options.SwaggerEndpoint("v1/swagger.json", "Demo Jwt Auth API V1");
            });

            app.UseMvc();
            app.Run(context => {
                context.Response.Redirect("swagger/");
                return(Task.CompletedTask);
            });

            DBinitialize.EnsureCreated(app.ApplicationServices);
        }
コード例 #6
0
        public static void Main(string[] args)
        {
            var host = BuildWebHost(args);

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;
                try
                {
                    DBinitialize.EnsureCreated(services);
                    SeedData.Initialize(services);
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occured creating and seeding the DB.");                                logger.LogError(ex, "An error occurred seeding the DB.");
                }
            }
            host.Run();
        }
コード例 #7
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            using (var scope = app.ApplicationServices.CreateScope())
            {
                var services = scope.ServiceProvider;

                try
                {
                    DBinitialize.EnsureCreated(services);
                    SeedData.Initialize(services);
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred seeding the DB.");
                }
            }
        }
コード例 #8
0
 public void Configure(IApplicationBuilder app)
 {
     app.UseMvc();
     DBinitialize.EnsureCreated(app.ApplicationServices);
     SeedData.Initialize(app.ApplicationServices);
 }