Вот мой код — Program.cs:
Код: Выделить всё
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.Configure(options =>
{
options.MaxRequestBodySize = null; // Set to 250 MB
});
builder.WebHost.UseKestrel(opt =>
{
opt.Limits.MaxRequestBodySize = null; // Set to unlimited
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
}
Код: Выделить всё
[HttpPost("file")]
[RequestSizeLimit((250 * 1024 * 1024))] // Set to 250 MB
public async Task File(IFormFile file)
{
var fileName = file.FileName;
return Ok(fileName);
}
InvalidOperationException: приложение работает внутри процесса IIS, но не настроено для использования сервера IIS
Подробнее здесь: https://stackoverflow.com/questions/792 ... asp-net-co