我想Exit sub
在 MVC 应用程序中使用类似的操作,并且我正在使用 c# 语言。
当我只是键入return
它显示一个错误。它要求强制ActionResult
。
[HttpPost]
public ActionResult Create(Location location)
{
if (ModelState.IsValid)
{
Validations v = new Validations();
Boolean ValidProperties = true;
EmptyResult er;
string sResult = v.Validate100CharLength(location.Name, location.Name);
if (sResult == "Accept")
{
ValidProperties = true;
}
else
{
//What should I write here ?
//I wan to write return boolean prperty false
// When I write return it asks for the ActionResult
}
if (ValidProperties == true)
{
db.Locations.Add(location);
db.SaveChanges();
return RedirectToAction("Index");
}
}
ViewBag.OwnerId = new SelectList(
db.Employees, "Id", "FirstName", location.OwnerId);
return View(location);
}