views:

22

answers:

1

Friends,

I do not know why, but every time I add a ModelErrror my session is lost. Someone tell me how I can work around / fix it?

                Session[CtSessionName + SessionId] = _ListaAcaoMenuInfo;

                AcaoMenuInfoExt _SelecionadoAcaoMenuExt = _ListaAcaoMenuInfo.Where(p => p.Id_acao == id).FirstOrDefault();
                if (_SelecionadoAcaoMenuExt.Is_AcaoInicial)
                {
                    ModelState.AddModelError(String.Empty, "Error! Try Again, and Again, And Again!");
                }
A: 

Sorry friend but thats impossible. AddModelError's code path never touches Session at all.

When you access session after the AddModelError its gone? Or are you outputting those values and they are not showing up on the screen?

jfar
My friend, this is embarrassing, but I found the problem.The problem was to send the object to the page. The random value of the Session was obtained properly, but it was not sent correctly.
Ph.E
You know how I can close this question?
Ph.E