Advertisement
joaopaulofcc

Untitled

Nov 17th, 2021
641
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.70 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 conexaoPostgre.Models;
  14.  
  15. namespace conexaoPostgre
  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.AddControllersWithViews();
  30.  
  31.             services.AddDbContext<BDContexto>(option =>
  32.                  option.UseNpgsql(Configuration.GetConnectionString("DefaultConnection"))
  33.              );
  34.         }
  35.  
  36.         // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  37.         public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  38.         {
  39.             if (env.IsDevelopment())
  40.             {
  41.                 app.UseDeveloperExceptionPage();
  42.             }
  43.  
  44.             app.UseCors(option => option.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
  45.  
  46.             app.UseHttpsRedirection();
  47.  
  48.             app.UseRouting();
  49.  
  50.             app.UseAuthorization();
  51.  
  52.             app.UseEndpoints(endpoints =>
  53.             {
  54.                 endpoints.MapControllers();
  55.             });
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement