Program.cs 997 B

1234567891011121314151617181920212223242526272829303132333435
  1. using Microsoft.EntityFrameworkCore;
  2. using Recepie.Data;
  3. var builder = WebApplication.CreateBuilder(args);
  4. // Add services to the container.
  5. builder.Services.AddControllersWithViews();
  6. // Configure MySQL database connection
  7. var connectionString = "Server=nordh.xyz;Port=3306;Database=recept;User=recepieUser;Password=v.FV-ssZPzVyev28;";
  8. builder.Services.AddDbContext<RecipeContext>(options =>
  9. options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)));
  10. var app = builder.Build();
  11. // Configure the HTTP request pipeline.
  12. if (!app.Environment.IsDevelopment())
  13. {
  14. app.UseExceptionHandler("/Home/Error");
  15. // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
  16. app.UseHsts();
  17. }
  18. app.UseHttpsRedirection();
  19. app.UseStaticFiles();
  20. app.UseRouting();
  21. app.UseAuthorization();
  22. app.MapControllerRoute(
  23. name: "default",
  24. pattern: "{controller=Recipe}/{action=Index}/{id?}");
  25. app.Run();