开发者

ModelState refresh in post to remove errors

Problem: ModelState is not valid, complaining that there is no Event.

I've tried associating it and done a TryUpdateModel

Inspecting raceViewModel it does look fine.

 [HttpPost]
    public ActionResult Create(RaceViewModel raceViewModel, Guid idEvent)
    {
        Event _event = uow.Events.Single(e => e.Id == idEvent);
        raceViewModel.RaceInVM.EventU = _event;
        TryUpdateModel<RaceViewModel>(raceViewModel);

        if (!ModelState.IsValid)
        {
           开发者_JAVA百科 SetupDropDownsStronglyTyped(raceViewModel);
            return View(raceViewModel);
        }


I think that your idEvent parameter may not be what you expect it to be. The uow.Events.Single call then fails and throws an exception (there is no Event with the provided Id).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜