[英]No parameterless constructor defined for this object. when Iam trying to update image
net-Mvc5我正在更新已经保存在数据库中的Imagepath,但出现此错误
没有为此对象定义无参数构造函数。
// Parameter less Constructor::
public EditclassWorkController()
{
}
// Code For Index Controller:
public ActionResult Index(HttpPostedFile file)
{
return View();
}
// Code for update ImagePath :
[HttpPost]
public ActionResult Edit(tbl_classWork vehi,HttpPostedFile file)
{
SchoolERP db = new SchoolERP();
tbl_classWork imgToSave =
(
from imga in db.tbl_classWork
where imga.Classwork_id == vehi.Classwork_id
select imga
).First();
if (ModelState.IsValid)
{
if (vehi != null)
{
imgToSave.class_file = file.ContentType;
var binaryReader = new BinaryReader(file.InputStream);
imgToSave.class_file = binaryReader.ReadBytes(file.ContentLength).ToString();
binaryReader.Close();
}
TryUpdateModel(imgToSave);
db.SaveChanges();
return RedirectToAction("Index");
}
//No path Found return Else part:
else
{
return View(vehi);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.