Код: Выделить всё
public async Task CreateVideoNewsAsync(string VideoName, IFormFile VideoFile)
Код: Выделить всё
@model CreateModalModel
@inject IStringLocalizer L
@{
Layout = null;
}
Код: Выделить всё
namespace huake.tennis.Web.Pages.News
{
public class CreateModalModel : tennisPageModel
{
[BindProperty]
public CreateNewsViewModel News{ get; set; }
private readonly ICourtAppService _courtAppService;
public CreateModalModel(
ICourtAppService courtAppService)
{
_courtAppService = courtAppService;
}
public void OnGet(string iVideoName, IFormFile iVideoFile)
{
News = new CreateNewsViewModel
{
VideoName = iVideoName,
VideoFile = iVideoFile,
};
}
public async Task OnPostAsync()
{
//将News.VideoFile实例化
await _courtAppService.CreateVideoNewsAsync(News.VideoName, News.VideoFile);
return NoContent();
}
public class CreateNewsViewModel
{
[Required]
[StringLength(100)]
public required string VideoName { get; set; }
[DisplayName("上传文件")]
public IFormFile VideoFile { get; set; }
}
}
}
Код: Выделить всё
2024-05-13 10:04:31.402 +08:00 [ERR] ---------- RemoteServiceErrorInfo ----------
{
"code": null,
"message": "您的请求无效!",
"details": "验证过程中检测到以下错误。\r\n - The VideoFile field is required.\r\n",
"data": {},
"validationErrors": [
{
"message": "The VideoFile field is required.",
"members": [
"videoFile"
]
}
]
}
Подробнее здесь: https://stackoverflow.com/questions/784 ... ui-but-can