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 a hospital swap by pulling the hospital ID, when I change the first time hospital from ID 1 to ID 2 works, but when I change it again it appears the following error:
No route in the route table Matches the supplied values.
Could someone help me?
What routes are you trying to?
– Leonel Sanches da Silva