我有一个正常工作的动作方法。这是代码:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include = "Id,Title,Content,Category,HeaderFilePath")] Blog blog, HttpPostedFileBase upload)
{
if (ModelState.IsValid)
{
if (upload != null && upload.ContentLength > 0)
{
if (blog.HeaderFilePath != string.Empty && blog.HeaderFilePath != null)
{
try
{
System.IO.File.Delete(HttpContext.Server.MapPath("~/") + "images/" + blog.HeaderFilePath);
}
catch (Exception)
{
//TODO: handle it properly
//throw;
}
}
blog.HeaderFilePath = Guid.NewGuid() + ".jpg";
CustomHttpPostedFile f = new CustomHttpPostedFile(upload.InputStream, "jpg", HttpContext.Server.MapPath("~/") + "images/" + blog.HeaderFilePath);
f.SaveAs(HttpContext.Server.MapPath("~/") + "images/" + blog.HeaderFilePath);
}
db.Entry(blog).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(blog);
}
这个Action方法没有问题,我错过了什么吗?
方法体上方的符号看起来像“0引用| 1请求,100%失败| 0例外”。
当我点击它时它并没有提供任何有用的信息。