Advertisement
joaopaulofcc

Untitled

Sep 15th, 2021
929
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.77 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.AspNetCore.Mvc;
  9. using Microsoft.Extensions.Configuration;
  10. using Microsoft.Extensions.DependencyInjection;
  11. using Microsoft.Extensions.Hosting;
  12. using Microsoft.Extensions.Logging;
  13.  
  14. using Microsoft.EntityFrameworkCore;
  15. using projetoTeste.Models;
  16.  
  17. namespace projetoTeste
  18. {
  19.     public class Startup
  20.     {
  21.         public Startup(IConfiguration configuration)
  22.         {
  23.             Configuration = configuration;
  24.         }
  25.  
  26.         public IConfiguration Configuration { get; }
  27.  
  28.         // This method gets called by the runtime. Use this method to add services to the container.
  29.         public void ConfigureServices(IServiceCollection services)
  30.         {
  31.             services.AddControllers();
  32.  
  33.             services.AddDbContext<BDContexto>(option =>
  34.                 option.UseMySQL("server=localhost;port=3306;user=root;password=root;database=projeto_teste")
  35.             );
  36.         }
  37.  
  38.         // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  39.         public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  40.         {
  41.             if (env.IsDevelopment())
  42.             {
  43.                 app.UseDeveloperExceptionPage();
  44.             }
  45.  
  46.             app.UseCors(option => option.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
  47.  
  48.             app.UseHttpsRedirection();
  49.  
  50.             app.UseRouting();
  51.  
  52.             app.UseAuthorization();
  53.  
  54.             app.UseEndpoints(endpoints =>
  55.             {
  56.                 endpoints.MapControllers();
  57.             });
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement