我是 mvc C# 的新手并且被卡住了。请告知如何解决此问题。我在添加时遇到错误。当我将鼠标悬停在红色波浪线上时,它显示“并非所有代码路径都返回值”
public ActionResult Add(ShapeInputModel dto, FormCollection collection)
{
var model = new GeoRegions();
if (TryUpdateModel(model))
{
var destinationFolder = Server.MapPath("/App_Data/KML");
var postedFile = dto.Shape;
if (postedFile != null)
{
var fileName = Path.GetFileName(postedFile.FileName);
var path = Path.Combine(destinationFolder, fileName);
postedFile.SaveAs(path);
//Save to Database
Db.AddGeoRegions(model);
return RedirectToAction("Index");
}
return View();
}
}