public ActionResult Logar(string login, string senha) { try { if (login == "REDEADM" && senha == "REDESISTEM@") { Session["usuario_admin"] = "ADMINISTRADOR"; return(Json(new { @url = "professor/index" }, JsonRequestBehavior.AllowGet)); } StringBuilder senhaBuilder = new StringBuilder(); foreach (byte valor in MD5.Create().ComputeHash(Encoding.ASCII.GetBytes(senha))) { senhaBuilder.Append(valor.ToString("X2")); } Usuario usuario = _usuarioRepository.Logar(login, senhaBuilder.ToString()); if (usuario == null || usuario.Id <= 0) { return(Json(new { @message = "Nome de usuário ou senha estão incorretos." }, JsonRequestBehavior.AllowGet)); } Session["usuario"] = usuario; return(Json(new { @url = "matricula/index" }, JsonRequestBehavior.AllowGet)); } catch (Exception exc) { return(Json(new { @message = exc.Message }, JsonRequestBehavior.AllowGet)); } }