asp.net-core - 在 Asp Core 中使用 IFormFile
问题描述
我用的是 asp core 2.2
[HttpPost]
[Route("Create")]
public IActionResult Create([FromForm]SubjectWebFullDto newWeb)
{
try
{
if (!ModelState.IsValid)
return BadRequest(new BadRequestError("Incorrect Model"));
if (string.IsNullOrEmpty(newWeb.SourceWeb))
return NotFound(new NotFoundError("Incorrect Model"));
var subject = _subjectService.Get(newWeb.SubjectId);
var newObj = newWeb.LoadFrom(subject.Guid);
_subjectWebService.Insert(newObj);
return Ok();
}
catch (System.Exception ex)
{
}
}
在本地和服务器上没有上传图像的所有东西都很好。在本地响应上传图片时 OK: Local Api Post Man
但在服务器 iis 中失败: Server Api Post Man
我正在使用服务器 iis 7 在服务器中上传图像有什么问题?
模型:
public class SubjectWebFullDto
{
public int WebId { get; set; }
public string ImageUrl { get; set; }
public IFormFile Image { get; set; }
[MaxLength(200)]
public string Name { get; set; }
[MaxLength(10)]
public string PublishDate { get; set; }
[MaxLength(1000)]
[Required]
public string SourceWeb { get; set; }
[MaxLength(300)]
[Required]
public string Lead { get; set; }
public string Body { get; set; }
[MaxLength(300)]
public string Descript { get; set; }
public int SubjectId { get; set; }
}
解决方案
推荐阅读
- python - 正则表达式:匹配带有侵入符号的单词
- sql - Azure SQL 数据迁移助手 (DMA) 错误 - 三个或四个部分名称
- mysql - 如何更改Mysql服务器主机名
- java - 基于字段值的杰克逊属性顺序
- rsa - 将 RSA 公钥从 der 转换为 pub
- python - 通过python获取特定的日期间隔
- listview - Flutter,如何让 SingleChildScrollView 中子部件的高度与父部件匹配?
- c# - 在 if 语句中使用方法
- javascript - Angular js在数据出现在表格之前从数据中删除逗号,],"
- asp.net - Asp.net MVC,实体框架如何将 + 1 添加到字符串中的数据