1
I have the following code:
public JsonResult salvaPaciente(string cns, string sexo, string dataNasc, string nome, string raca,
                                    string cep, string ibge, string logradouro, string endereco, string numero,
                                    string complemento, string bairro, string telefone, string email)
    {
        byte[] bytes = System.Text.Encoding.GetEncoding("iso-8859-8").GetBytes(nome);
        nome = System.Text.Encoding.UTF8.GetString(bytes);
        paciente oPaciente = new paciente()
        {
            bairro = bairro,
            cep = cep,
            cns = cns,
            complemento = complemento,
            dataNasc = Convert.ToDateTime(dataNasc),
            email = email == "" ? " " : email,
            endereco = endereco,
            ibge = ibge,
            logradouro = logradouro,
            nacionalidade = "010",
            nomePaciente = nome,
            numero = numero,
            raca = raca,
            sexo = sexo,
            telefone = telefone
        };
        modelOff.pacientes.Add(oPaciente);
        try
        {
            modelOff.SaveChanges();
            return Json("sim", JsonRequestBehavior.AllowGet);
        }
        catch
        {
            return Json("nao", JsonRequestBehavior.AllowGet);
        }
    }
It worked normally and stopped working from nothing with the following error:
[Formatexception: String was not recognized as a Valid Datetime.]
A string dataNasc is '24/06/1979'
Already tried in date format 'yyyy-mm-dd' in case your date would be 1979-06-24
– Nataniel Soares Rodrigues
See if the format on the server is Brazilian, sometimes changed the environment and need to change the web.config to accept this format.
– Rodrigo Prieto
@Natanielsoaresrodrigues your tip worked. if you want, you can post the answer to earn the points
– Italo Rodrigo