Это один из примеров моей пробной версии:
Код: Выделить всё
// old method that needs to be redirected
[HttpPost("file", Name = nameof(UpooadFileExample))]
public async Task UpooadFileExample(IFormFile file1)
{
var contentDisposition = new ContentDisposition
{
FileName = "file.xml",
DispositionType = DispositionTypeNames.Attachment
};
var stream = file1.OpenReadStream();
var file = new FormFile(stream, 0, stream.Length, "file", "file.xml")
{
Headers = new HeaderDictionary(
new Dictionary { { "Content-Disposition", contentDisposition.ToString() } })
};
// https://procodeguide.com/programming/redirect-a-request-in-aspnet-core/
return RedirectToActionPermanent(nameof(UpooadFileExampleV2), new { file = file, value_1 = "teste" });
}
// new method
[HttpPost("v2/file", Name = nameof(UpooadFileExampleV2))]
public async Task UpooadFileExampleV2(UploadFile request)
{
// do stuff
return new Result();
}
public record UploadFile
{
public required IFormFile File { get; set; }
public required string Value1 { get; set; }
}
Я пробовал некоторые варианты на C#, например RedirectToActionPermanent >/
Код: Выделить всё
RedirectPermanent/RedirectToActionPermanentЯ получаю сообщения об ошибках, например
Неподдерживаемый тип носителя
и
Метод не разрешен
Подробнее здесь: https://stackoverflow.com/questions/783 ... re-web-api
Мобильная версия