No route in the route table matches the supplied values

0

I have the following route settings:

        [HttpPost]
        [Authorize(Roles = "Perfil Administrador, Master")]
        public ActionResult AlterarHospital(int id, string url)
        {
            var rota = url.Split('/').ToArray();
            string[] routes = { rota[rota.Length - 1], rota[rota.Length - 2], rota[rota.Length - 3] };

            if (routes[0].Contains("?"))
            {
                //Limpar URL
                routes[0] = routes[0].Remove(routes[0].IndexOf("?"), routes[0].Length - routes[0].IndexOf("?"));
            }

            //Alterar Hospital Logado para que o administrador possa visualizar dados de outros hospitais 
            var hospital = _hospitalService.GetById(id);
            HttpCookie cookie = Request.Cookies["Usuario"];
            cookie.Values.Set("HospitalId", hospital.HospitalId.ToString());
            cookie.Values.Set("HospitalNome", Server.UrlEncode(hospital.hospital));
            Response.Cookies.Set(cookie);

            return RedirectToAction(routes[0], routes[1], new { area = routes[2] });
        }

I'm doing an exchange of hospitals pulling the ID of the hospital, when I change the first time hospital from ID 1 to ID 2 it works, more when I'm going to change it again the following error appears:

  

No route in the route table matches the supplied values.

Could anyone help me?

    
asked by anonymous 02.03.2017 / 15:30

1 answer

0
   public ActionResult AlterarHospital(int id)
        {            
            //Alterar Hospital Logado para que o administrador possa visualizar dados de outros hospitais 
            var hospital = _hospitalService.GetById(id);
            Cookies.SetCookie("hid", hospital.HospitalId.ToString());
            Cookies.SetCookie("hname", Server.UrlEncode(hospital.hospital));

            return RedirectToAction("Index", "Cadastro", new { area = "Formulario" });
        }

I solved!

    
30.03.2017 / 17:23