保存客户端名称时,它显示clientID的值为null。 我尝试了很多,但无法得到解决方案。 这是代码:
控制器:
[SpecialAuthorize("Client_Add")]
public ActionResult Create()
{
var client = new OData.Client();
client.Picture = Guid.NewGuid().ToString();
SetMyBag(client);
return View("Edit", client);
}
[HttpPost]
[SpecialAuthorize("Client_Add")]
public ActionResult Create(OData.Client model)
{
var client = new OData.Client();
if (ModelState.IsValid == true)
{
db.Clients.Add(client);
db.SaveChanges();
db.LogHistory(new Activity(ActionEnum.Created, model.ClientId, model.ResellerName, model.ClientId, "Client"));
return RedirectToAction("Index");
}
SetMyBag(client);
return View("Edit", model);
}
答案 0 :(得分:0)
知道了。 我只是错误地把参数弄错了。
[SpecialAuthorize("Client_Add")]
public ActionResult Create(Model.Client model)
{
//var client = new Model.Client();
if (ModelState.IsValid)
{
db.Clients.Add(model);
db.SaveChanges();
db.LogHistory(new Activity(ActionEnum.Created, model.ClientId, model.ResellerName, model.ClientId, "Client"));
return RedirectToAction("Index");
}
SetMyBag(model);
return View("Edit", model);
}