// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(Microsoft.AspNetCore.Builder.IApplicationBuilder app, IHostingEnvironment env, DataInitializer initializer) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { // 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.UseAuthentication(); app.UseCors("AllowAllOrigins"); app.UseHttpsRedirection(); app.UseMvc(); app.UseSwaggerUi3(); app.UseSwagger(); initializer.InitializeData().Wait(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(Microsoft.AspNetCore.Builder.IApplicationBuilder app, IHostingEnvironment env) { app.UseCors("any"); app.UseStaticFiles(); app.UseAuthentication(); if (env.IsDevelopment()) { //app.UseDeveloperExceptionPage(); } app.UseStatusCodePages(); app.UseJimuSwagger(); // jimu client Jimu.IApplication host; #if DEBUG if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SERVICE_GROUPS"))) { host = new ApplicationClientBuilder(new ContainerBuilder(), "JimuAppClientSettings.local").Build(); } else { host = new ApplicationClientBuilder(new ContainerBuilder()).Build(); } #else host = new ApplicationClientBuilder(new ContainerBuilder()).Build(); #endif app.UseJimu(host); host.Run(); }
public static void AddDefaultConfiguration(this Microsoft.AspNetCore.Builder.IApplicationBuilder applicationBuilder, IWebHostEnvironment webHostEnviroment) { if (webHostEnviroment.IsDevelopment()) { applicationBuilder.UseDeveloperExceptionPage(); applicationBuilder.UseDatabaseErrorPage(); } else { applicationBuilder.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. applicationBuilder.UseHsts(); } applicationBuilder.UseHttpsRedirection(); applicationBuilder.UseStaticFiles(); applicationBuilder.UseRouting(); applicationBuilder.UseAuthentication(); applicationBuilder.UseAuthorization(); applicationBuilder.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); endpoints.MapRazorPages(); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(Microsoft.AspNetCore.Builder.IApplicationBuilder app, IHostingEnvironment env) { app.UseStaticFiles(); app.UseAuthentication(); if (env.IsDevelopment()) { //app.UseDeveloperExceptionPage(); } app.UseStatusCodePages(); app.UseJimuSwagger(); // jimu client var host = new ApplicationClientBuilder(new ContainerBuilder()) //.UseLog4netLogger(new JimuLog4netOptions ////.UseNLogger(new LogOptions //{ // EnableConsoleLog = true, // EnableFileLog = true, // FileLogLevel = LogLevel.Info | LogLevel.Error, //}) //.UseConsulForDiscovery(new Client.Discovery.ConsulIntegration.ConsulOptions("127.0.0.1", 8500, "hello")) //.UseDotNettyForTransfer() //.UseHttpForTransfer() //.UsePollingAddressSelector() //.UseServerHealthCheck(1) //.SetDiscoveryAutoUpdateJobInterval(new Client.Discovery.Implement.DiscoveryOptions(1)) //.UseToken(() => { var headers = JimuHttpContext.Current.Request.Headers["Authorization"]; return headers.Any() ? headers[0] : null; }) //.UseJoseJwtForOAuth<HttpAddress>(new Client.Auth.JwtAuthorizationOptions() //{ // ServerIp = "127.0.0.1", // ServerPort = 5001, // SecretKey = "test", // ExpireTimeSpan = new TimeSpan(1, 0, 0), // TokenEndpointPath = "/api/client/token", // ValidateLifetime = true, // CheckCredential = o => // { // if (o.UserName == "admin" && o.Password == "admin") // { // o.AddClaim("department", "IT部"); // } // else // { // o.Rejected("401", "acount or password incorrect"); // } // } //}) .Build(); app.UseJimu(host); host.Run(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(Microsoft.AspNetCore.Builder.IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IServiceProvider serviceProvider, RoleManager <WebRole> roleManager, UserManager <WebUser> userManager) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { HotModuleReplacement = true, //HotModuleReplacementEndpoint = "/dist/__webpack_hmr", ReactHotModuleReplacement = true }); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } // Add custom middleweara for thumbnails and images. app.UseThumbnailHandler(); app.UseImageHandler(); // app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), specifying the Swagger JSON endpoint. app.UseSwagger(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); routes.MapRoute( name: "account", template: "{controller=Account}/{action=Index}/{id?}"); routes.MapSpaFallbackRoute( name: "spa-fallback", defaults: new { controller = "Home", action = "Index" }); }); CreateRoles(roleManager, userManager); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env) { app.UseDeveloperExceptionPage(); app.UseStatusCodePages(); app.UseStaticFiles(); //app.UseMvcWithDefaultRoute(); I am going to replace this with app.UseMvc() and passing to this one my route ; app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"//this template is going to be use to match incoming request with this pattern ); } ); // In complex application we can use several routes by calling MapRoute several times with different routes; }
} // makes EFProductRepository take the place of IProductRepository in the code //This method is called after the 'webHost.Run();' line in the Program.cs is called. //when called, two parameters are passed in. They are app and env. //sets up stuff //doesn't return anything public void Configure(Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseStatusCodePages(); } else { app.UseExceptionHandler("/Error"); } app.UseStaticFiles(); app.UseSession(); app.UseAuthentication(); //next line routes requests to the application root to the appropriate controller based on the url app.UseMvc(routes => { routes.MapRoute( name: null, template: "{category}/Page{productPage:int}", defaults: new { controller = "Product", action = "List" }); routes.MapRoute( name: null, template: "Page{productPage:int}", defaults: new { controller = "Product", action = "List", productPage = 1 }); routes.MapRoute( name: null, template: "{category}", defaults: new { controller = "Product", action = "List", productPage = 1 }); routes.MapRoute( name: null, template: "", defaults: new { controller = "Product", action = "List", productPage = 1 }); routes.MapRoute( name: null, template: "{controller}/{action}/{id?}"); }); }
// 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) { app.UseAuthentication(); app.UseRepositorySyncHub(); app.UseCoddeeDynamicApi(); }
private void ConfigureJWT(Microsoft.AspNetCore.Builder.IApplicationBuilder app) { app.UseAuthentication(); }