// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseCors( builder => builder.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin()); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } #region InitStaticFiles Images string pathRoot = InitStaticFiles .CreateFolderServer(env, this.Configuration, new string[] { "ImagesPath" }); app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(pathRoot), RequestPath = new PathString('/' + Configuration.GetValue <string>("UrlImages")) }); #endregion app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); }); SeederDB.SeedDataByAS(app.ApplicationServices); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { #region CORS app.UseCors(x => x .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader()); #endregion if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } #region InitStaticFiles Images string pathRootForPhotos = InitStaticFiles .CreateFolderServer(env, this.Configuration, new string[] { "ImagesPath" }); string pathRootForBooks = InitStaticFiles.CreateFolderServer(env, this.Configuration, new string[] { "BooksPath" }); app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(pathRootForPhotos), RequestPath = new PathString('/' + Configuration.GetValue <string>("UrlImages")) }); app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(pathRootForBooks), RequestPath = new PathString('/' + Configuration.GetValue <string>("UrlBooks")) }); #endregion app.UseMiddleware <GlobalExceptionHandlerMiddleware>(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); #region Swagger app.UseSwagger(); app.UseSwaggerUI(c => { c.IndexStream = () => GetType().Assembly.GetManifestResourceStream("LibShare.Api.Swagger.index.html"); c.SwaggerEndpoint("/swagger/v1/swagger.json", "LIBSHARE API V1"); }); #endregion SeederDB.SeedDataByAS(app.ApplicationServices); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.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. app.UseHsts(); } // app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); #region InitStaticFiles Images string pathRoot = InitStaticFiles .CreateFolderServer(env, this.Configuration, new string[] { "ImagesPath" }); app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(pathRoot), RequestPath = new PathString('/' + Configuration.GetValue <string>("UrlImages")) }); #endregion app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); endpoints.MapRazorPages(); }); SeederDB.SeedData(app.ApplicationServices, env, this.Configuration); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto }); //app.UseCors( // builder => builder.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin()); app.UseSignalR( routes => { routes.MapHub <ChatHub>("/chat"); }); app.UseAuthentication(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); } //app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSpaStaticFiles(); app.UseSession(); #region InitStaticFiles Images string pathRoot = InitStaticFiles .CreateFolderServer(env, this.Configuration, new string[] { "ImagesPath" }); app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(pathRoot), RequestPath = new PathString("/" + Configuration.GetValue <string>("ImagesUrl")) }); app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(pathRoot), RequestPath = new PathString("/" + Configuration.GetValue <string>("ImagesHotelUrl")) }); #endregion ; if (!Directory.Exists(Path.Combine(Directory.GetCurrentDirectory(), @"UserImages"))) { Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), @"UserImages")); } app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"UserImages")), RequestPath = new PathString("/UserImages") }); if (!Directory.Exists(Path.Combine(Directory.GetCurrentDirectory(), @"Uploaded"))) { Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), @"Uploaded")); } app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider( Path.Combine(Directory.GetCurrentDirectory(), "Uploaded")), RequestPath = "/Uploaded" }); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{action=Index}/{id?}"); }); app.UseSpa(spa => { spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseReactDevelopmentServer(npmScript: "start"); } }); SeederDB.SeedDataByAS(app.ApplicationServices, env, this.Configuration); SendEmailService.SendInfoStartApp(Configuration, env); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { ///app.UseSwagger(); //app.UseSwaggerUI(c => //{ // c.SwaggerEndpoint("v1/swagger.json", "My API V1"); //}); app.UseCors( builder => builder.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin()); app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto }); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); // 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.UseHttpsRedirection(); app.UseStaticFiles(); //app.UseSpaStaticFiles(); app.UseSession(); #region InitStaticFiles Images string pathRoot = InitStaticFiles .CreateFolderServer(env, this.Configuration, new string[] { "ImagesPath" }); app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(pathRoot), RequestPath = new PathString('/' + Configuration.GetValue <string>("UrlImages")) }); #endregion #region InitStaticFiles UserImages string pathuser = InitStaticFiles .CreateFolderServer(env, this.Configuration, new string[] { "ImagesPath", "ImagesUserPath" }); app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(pathuser), RequestPath = new PathString('/' + Configuration.GetValue <string>("UserUrlImages")) }); #endregion app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller}/{action=Index}/{id?}"); }); app.UseSpa(spa => { spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseReactDevelopmentServer(npmScript: "start"); } }); //await Seed.SeedData(app.ApplicationServices, env, this.Configuration); }
// 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, IServiceProvider serviceProvider) { app.UseCors( builder => builder.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin()); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseAuthentication(); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSpaStaticFiles(); app.UseSession(); // SeederDB.SeedData(app.ApplicationServices, env, this.Configuration); #region InitStaticFiles ClientImages string pathClient = InitStaticFiles .CreateFolderServer(env, this.Configuration, new string[] { "ImagesPath", "ImagesPathUsers" }); app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(pathClient), RequestPath = new PathString("/" + Configuration.GetValue <string>("UserUrlImages")) }); #endregion ; app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{action=Index}/{id?}"); }); app.UseSpa(spa => { spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseReactDevelopmentServer(npmScript: "start"); } }); //app.UseSignalR(routes => //{ // routes.MapHub<ChatHub>("/chat"); //}); //app.UseSignalR(route => //{ // route.MapHub<ChatService>("/api/clientwaiter"); //}); }