// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseApplicationInsightsRequestTelemetry(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Main/Error"); } app.UseApplicationInsightsExceptionTelemetry(); app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Main}/{action=index}/{id?}" ); }); app.Run(async(context) => { await context.Response.WriteAsync("Hello World!"); }); }
// 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, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(minLevel: LogLevel.Trace); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); // ************************************************** // Note: // نکته مهم آن است که محل نوشتن دستور ذیل بسیار // اهمیت دارد، اگر بعد از دستور بعدی نوشته شود، عمل نمیکند // Note: For all Actions of Controllers app.UseCors("AllowSpecificOrigin"); // ************************************************** app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{culture=fa-IR}/{controller=Home}/{action=Index}/{id?}"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); loggerFactory.AddNLog();//添加NLog Mapper.Initialize(x => x.CreateMap <PageData <TGuide>, PageData <GuideDto> >()); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseHttpsRedirection(); app.UseAuthentication(); app.UseMvc(); #region swagger ui app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "我的API V1"); }); #endregion }
// 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.AddFile("Logs/myapp-{Date}.txt"); loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseSession(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{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) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseIISPlatformHandler(); app.UseStaticFiles(); app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory) { loggerFactory.AddConsole((text, logLevel) => logLevel >= LogLevel.Warning); app.ConfigureAuthentication(_configuration); app.UseCors(defaultName); app.UseMvc(); Mvc.Server.MongoSeeder.InitializeMongoClientsAsync(app.ApplicationServices, CancellationToken.None).GetAwaiter().GetResult(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, UserManager <ApplicationUser> userManager, ApplicationDbContext dbContext, RoleManager <IdentityRole> roleManager, ILoggerFactory loggerFactory) { if (env.IsProduction()) { loggerFactory.AddAzureWebAppDiagnostics( new AzureAppServicesDiagnosticsSettings { OutputTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss zzz} [{Level}] {RequestId}-{SourceContext}: {Message}{NewLine}{Exception}" }); } loggerFactory.AddConsole().AddDebug(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); app.UseDatabaseErrorPage(); } else { //app.UseDeveloperExceptionPage(); //app.UseBrowserLink(); //app.UseDatabaseErrorPage(); app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseAuthentication(); app.UseSession(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); if (_environment.IsProduction() || _environment.IsStaging()) { dbContext.Database.Migrate(); } DbInitializer.Initializer(dbContext, userManager, roleManager); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, Microsoft.Extensions.Logging.ILoggerFactory logger) { var pathBase = Configuration["PATH_BASE"]; if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); } logger.AddConsole(Configuration.GetSection("Logging")); app.UseCors("CorsPolicy"); }
// 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("Serilog")); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "API Test Service"); }); app.UseMvc(); }
/// <summary/> public void Configure( IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { try { loggerFactory.AddConsole(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseCors(c => { c.AllowAnyHeader(); c.AllowAnyMethod(); c.AllowAnyOrigin(); }); app.UseMvcWithDefaultRoute(); app.UseHttpsRedirection(); app.UseMvc(); var pathBase = _configuration["PATH_BASE"]; app.UseSwagger(); app.UseSwaggerUI(s => { s.SwaggerEndpoint($"{(string.IsNullOrEmpty(pathBase) ? string.Empty : pathBase)}/swagger/v{Version}/swagger.json", $"{ProjectName} API"); }); } catch (Exception ex) { _serilog?.Error("Erro no Configure: " + ex); } }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory) { loggerFactory.AddConsole(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); app.UseStaticFiles(); app.Run(async(context) => { await context.Response.WriteAsync("Hello World!"); }); }
// 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, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseStaticFiles(); app.UseIdentity(); // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715 app.UseSession(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); app.UseStatusCodePagesWithRedirects("Account/AccessDenied"); DatabaseInitializer.Initialize(app.ApplicationServices); }