RIG000
دوشنبه 13 آبان 1392, 08:44 صبح
این خطا رو تو این کدی که نوشتم میده
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Source Error:
Line 30: { Line 31: ToranjEntities3 db = new ToranjEntities3(); Line 32: var uploadedFile = Request.Files[0]; Line 33: var fileName = Path.GetFileName(uploadedFile.FileName); Line 34: var fileSavePath = Server.MapPath("/Images/Laptop" + fileName);
اینم کل کد CREATE A RECORD ...
[HttpPost]
public ActionResult CreateLoptop( tblLaptopProduct Laptop )
{
ToranjEntities3 db = new ToranjEntities3();
var uploadedFile = Request.Files[0];
var fileName = Path.GetFileName(uploadedFile.FileName);
var fileSavePath = Server.MapPath("/Images/Laptop" + fileName);
uploadedFile.SaveAs(fileSavePath);
Laptop.ImageSrc = fileName;
db.tblLaptopProducts.Add(Laptop);
db.SaveChanges();
return View();
}
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Source Error:
Line 30: { Line 31: ToranjEntities3 db = new ToranjEntities3(); Line 32: var uploadedFile = Request.Files[0]; Line 33: var fileName = Path.GetFileName(uploadedFile.FileName); Line 34: var fileSavePath = Server.MapPath("/Images/Laptop" + fileName);
اینم کل کد CREATE A RECORD ...
[HttpPost]
public ActionResult CreateLoptop( tblLaptopProduct Laptop )
{
ToranjEntities3 db = new ToranjEntities3();
var uploadedFile = Request.Files[0];
var fileName = Path.GetFileName(uploadedFile.FileName);
var fileSavePath = Server.MapPath("/Images/Laptop" + fileName);
uploadedFile.SaveAs(fileSavePath);
Laptop.ImageSrc = fileName;
db.tblLaptopProducts.Add(Laptop);
db.SaveChanges();
return View();
}