Request.Files.Count showing error

Ram 21 Reputation points
2022-06-14T14:05:52.08+00:00

211327-error.jpg

Hi guys what should be the problem for my code showing error to the Files see the pictures

Developer technologies | ASP.NET | ASP.NET Core
0 comments No comments
{count} votes

Accepted answer
  1. Michael Taylor 60,161 Reputation points
    2022-06-14T14:28:39.31+00:00

    If you mouse over the error it'll tell you what is wrong. There is no Files property on Request in ASP.NET Core. Files are accessible from Request.Form.Files. Note that it could be empty so you need to handle the fact that there may be none.

       var files = Request.Form?.Files;  
       if (files?.Any() ?? false)  
       {  
          ...  
       }  
    
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.