ASP MVC DateTime validation error

前端 未结 5 1727
轮回少年
轮回少年 2021-01-26 08:28

In asp.net MVC 5, I have a form that displays data from a DTO object:

public class FieldDTO
{
    [DataType(DataType.DateTime)]
    [DisplayFormat(ApplyFormatInE         


        
5条回答
  •  甜味超标
    2021-01-26 09:10

    Just in case this happens to anyone else. I was originally having a validation error because my iOS app in swift was sending unix time. I diagnosed that with a app.using block that read json from the request body. Then, I changed the swift date to iso but it wouldn't work. I spent several hours before I realized, once the diagnostic piece of code read the body content, nothing else could... so it was generating a validation error (but now for a different reason). If anyone happened to peek at your content the same way, remember to remark it out. You can't seek on the Body stream at least in .net core 2.2.

提交回复
热议问题