32 lines
799 B
C#
32 lines
799 B
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
builder.Services.AddDbContext<MvcContractContext>(options =>
|
|
options.UseSqlServer(builder.Configuration.GetConnectionString("MvcContractContext") ?? throw new InvalidOperationException("Connection string 'MvcContractContext' not found.")));
|
|
|
|
|
|
builder.Services.AddControllersWithViews();
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.UseExceptionHandler("/Home/Error");
|
|
app.UseHsts();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
app.UseStaticFiles();
|
|
|
|
app.UseRouting();
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllerRoute(
|
|
name: "default",
|
|
pattern: "{controller=Home}/{action=Index}/{id?}");
|
|
|
|
app.Run();
|