I have the following C # code snippet in an ASHX or Generic Handler file:
public override void ProcessRequest(HttpContext contexto)
{
string destino = contexto.Request["destino"];
string variables = "?";
string valor = "";
foreach (string nombre in contexto.Request.QueryString)
{
if (nombre == "destino")
{
continue;
}
else
{
if (contexto.Request.QueryString[nombre] != "")
{
valor = contexto.Request.QueryString[nombre];
variables += nombre + "=" + valor + "&";
}
}
}
variables = variables.Substring(0, variables.Length - 1);
if (destino != null && destino != "")
{
switch (destino)
{
case "coordenadasPorMunicipios": contexto.Response.Redirect("./admon/coordenadasPorMunicipios/CoordenadasPorMunicipiosControl.ashx" + variables);
break;
case "departamentos": contexto.Response.Redirect("./admon/departamentos/DepartamentosControl.ashx" + variables);
break;
case "municipios": contexto.Response.Redirect("./admon/municipios/MunicipiosControl.ashx" + variables);
break;
case "negocios": contexto.Response.Redirect("./admon/negocios/NegociosControl.ashx" + variables);
break;
case "paises": contexto.Response.Redirect("./admon/paises/PaisesControl.ashx" + variables);
break;
case "sectoresIndustria": contexto.Response.Redirect("./admon/sectoresIndustria/SectoresIndustriaControl.ashx" + variables);
break;
case "sectoresIndustriaPorNegocio": contexto.Response.Redirect("./admon/sectoresIndustriaPorNegocio/SectoresIndustriaPorNegocioControl.ashx" + variables);
break;
case "tiposNegocioPorNegocio": contexto.Response.Redirect("./admon/tiposNegocioPorNegocio/TiposNegocioPorNegocioControl.ashx" + variables);
break;
case "tiposNegocios": contexto.Response.Redirect("./admon/tiposNegocios/TiposNegociosControl.ashx" + variables);
break;
case "usuarios": contexto.Response.Redirect("./admon/usuarios/UsuariosControl.ashx" + variables);
break;
}
}
}
It works great for GET vars, I mean those that are sent to the URL, but I want to do this for POST rollers.
I tried to make an HttpContext object for each of them, but I received a message stating that the HttpContext class does not have an Enumerator inmpelementation function.
Any idea how I can do this for GET and POST vars ??
Thanks for the help!
user352353
source
share