Im trying to figure out a code that is not working
but I recieve no information even when i go to
Tools > options -> project and solutions -> build and run
I would like to see feedback from every step I take
In that way i can figure out how to fix the problem
right now i have no clue.
this is my code :
- public async Task<IActionResult> Create([Bind("ProductId,ProductTitle,ProductDiscription,Price,quantity,HeaderImage")] ProductWithImages productWithImages, ProductImages productImages)
- {
- Guid NewProductId = Guid.NewGuid();
- string uploadPath = Path.Combine(_webhostenv.WebRootPath, "Images2");
-
- if (ModelState.IsValid)
- {
-
- string FileName = Guid.NewGuid().ToString() + productWithImages.HeaderImage.FileName;
- string FilePath = Path.Combine(uploadPath, FileName);
- productWithImages.HeaderImage.CopyTo(new FileStream(FilePath, FileMode.Create));
-
- ProductWithImagesDb newproduct = new ProductWithImagesDb()
- {
- ProductId = NewProductId,
- ProductTitle = productWithImages.ProductTitle,
- ProductDiscription = productWithImages.ProductDiscription,
- Price = productWithImages.Price,
- quantity = productWithImages.quantity,
- HeaderImage = FileName,
-
- };
- _context.Add(newproduct);
- await _context.SaveChangesAsync();
- return RedirectToAction(nameof(Index));
- }
-
- return View();
it skips the "
if(ModelState.IsValid)"While all field where filled (I get no red "asp-validation-for" warning text as wel)
and I get no error or information whatso ever
if you are an expert in coding you probably would see the problem
but as a beginner like me it makes it pretty difficult figering out problems
and to learn from those mistakes.