How to prevent loosing IFormFile data on postback in ASP.NET core 2 razor page?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


How to prevent loosing IFormFile data on postback in ASP.NET core 2 razor page?



I'm using IFormFile type to save uploaded file to my database. It works fine when I capture the file at first call of OnPost method. But when it needs a postback (e.x. ModelState.Isvalid == false) then I loose data on second call of OnPost method even using BindProperty attribute. How can I fix this?


IFormFile


OnPost


ModelState.Isvalid == false


OnPost


BindProperty



Property definition:


[BindProperty]
public IFormFile Photo { get; set; }



Thanks in advance for taking your time.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

Visual Studio Code: How to configure includePath for better IntelliSense results