osyris zosar

osyris zosar

  • NA
  • 289
  • 23.6k

How to see more Errors and information while debugging

Apr 2 2021 8:30 AM
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 :
  1. public async Task<IActionResult> Create([Bind("ProductId,ProductTitle,ProductDiscription,Price,quantity,HeaderImage")] ProductWithImages productWithImages, ProductImages productImages)  
  2.       {  
  3.               Guid NewProductId = Guid.NewGuid();  
  4.               string uploadPath = Path.Combine(_webhostenv.WebRootPath, "Images2");  
  5.   
  6.               if (ModelState.IsValid)  
  7.               {  
  8.   
  9.                   string FileName = Guid.NewGuid().ToString() + productWithImages.HeaderImage.FileName;  
  10.                   string FilePath = Path.Combine(uploadPath, FileName);  
  11.                   productWithImages.HeaderImage.CopyTo(new FileStream(FilePath, FileMode.Create));  
  12.   
  13.                   ProductWithImagesDb newproduct = new ProductWithImagesDb()  
  14.                   {  
  15.                       ProductId = NewProductId,  
  16.                       ProductTitle = productWithImages.ProductTitle,  
  17.                       ProductDiscription = productWithImages.ProductDiscription,  
  18.                       Price = productWithImages.Price,  
  19.                       quantity = productWithImages.quantity,  
  20.                       HeaderImage = FileName,  
  21.                         
  22.                   };  
  23.    _context.Add(newproduct);  
  24.                   await _context.SaveChangesAsync();  
  25.                   return RedirectToAction(nameof(Index));  
  26.               }  
  27.           
  28.           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.
 

Answers (2)