C#C
C#9mo ago
morry329#

Cannot resolve symbol 'HttpPostedFileBase'

My IDE does not recognise HttpPostedFileBase although my code declared using System.Web as per documentation

 [HttpPost]
    public async Task <JsonResult> CreateUser([Bind("ListingName")]ListingProjects_ver2 obModel, List<IFormFile> file) 
    {
        try
        {
            if (obModel.Id == null)
            {
                if (obModel.ListingName == null)
                {
                    return Json(obModel,  new JsonException());
                }
                
                _context.ListingVer2_DBTable.Add(obModel);
                //OnPostUploadAsync(file);
                Console.WriteLine($"if name is null {obModel.ListingName}");
                HttpPostedFileBase file = HttpContext.Request.Files[0]; //HttpPostedFileBase does not get recognised 

                string fileName = Path.GetFileNameWithoutExtension(file.FileName);
                string extension = Path.GetExtension(file.FileName);
                fileName = fileName + extension;
                var ImagePath = "~/Image/" + fileName;
                fileName = Path.Combine(Server.MapPath("~/Image/"), fileName);
                file.SaveAs(fileName);
                _context.SaveChanges();
                
                
                return Json(obModel, fileName);
            }
            else
            {
                _context.ListingVer2_DBTable.Update(_listingProjectsDto);
            }
            
            return Json(obModel);
            
        }catch (Exception ex)
        {
            Console.WriteLine($"you got an exception {ex}");
            return Json(obModel);
        }
    }


Could anyone tell me why my IDE (Rider) does not recognise? Do I apply the helper that we don't use anymore etc?
Was this page helpful?