40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Assignment3.Data;
|
|
using Assignment3.Middleware;
|
|
namespace Assignment3
|
|
{
|
|
public class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
builder.Services.AddDbContext<Assignment3Context>(options =>
|
|
options.UseSqlServer(builder.Configuration.GetConnectionString("Assignment3Context") ?? throw new InvalidOperationException("Connection string 'Assignment3Context' not found.")));
|
|
|
|
// Add services to the container.
|
|
|
|
//builder.Services.AddControllers();
|
|
builder.Services.AddControllers(opts =>
|
|
{
|
|
opts.ReturnHttpNotAcceptable = true;
|
|
})
|
|
.AddXmlDataContractSerializerFormatters();
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllers();
|
|
|
|
app.UseMiddleware<ErrorlogMiddleware>();
|
|
|
|
app.Run();
|
|
}
|
|
}
|
|
}
|