Advertisement
joaopaulofcc

Untitled

Nov 3rd, 2021
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Microsoft.AspNetCore.Builder;
  6. using Microsoft.AspNetCore.Hosting;
  7. using Microsoft.AspNetCore.HttpsPolicy;
  8. using Microsoft.Extensions.Configuration;
  9. using Microsoft.Extensions.DependencyInjection;
  10. using Microsoft.Extensions.Hosting;
  11.  
  12. using Microsoft.EntityFrameworkCore;
  13. using projetoPostgre.Models;
  14.  
  15. namespace projetoPostgre
  16. {
  17. public class Startup
  18. {
  19. public Startup(IConfiguration configuration)
  20. {
  21. Configuration = configuration;
  22. }
  23.  
  24. public IConfiguration Configuration { get; }
  25.  
  26. // This method gets called by the runtime. Use this method to add services to the container.
  27. public void ConfigureServices(IServiceCollection services)
  28. {
  29. services.AddEntityFrameworkNpgsql().AddDbContext<BDContexto>(opt =>
  30. opt.UseNpgsql(Configuration.GetConnectionString("BDConection")));
  31. }
  32.  
  33. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  34. public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  35. {
  36. if (env.IsDevelopment())
  37. {
  38. app.UseDeveloperExceptionPage();
  39. }
  40.  
  41. app.UseCors(option => option.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
  42.  
  43. app.UseHttpsRedirection();
  44.  
  45. app.UseRouting();
  46.  
  47. app.UseAuthorization();
  48.  
  49. app.UseEndpoints(endpoints =>
  50. {
  51. endpoints.MapControllers();
  52. });
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement