Go to another controller from javascript

4

I want to redirect from a view to a controller that is a higher level, for that I use @url.action in this way

miUrl = '@Url.Action("CambiarEstadoVisita", "~/Areas/Visitas/Visita")';

But the link it generates is this:

http://localhost:10174/Mantenimiento/~/Areas/Visitas/Visita/CambiarEstadoVisita

How can I go backwards?

    
asked by Borja Calvo 24.08.2016 в 10:23
source

2 answers

5

I've already solved it. Instead of using url.Action that would not let me navigate backwards with the ../

miUrl = '@Url.Action("CambiarEstadoVisita", "../../Visitas/Visita")';

the url create it as string

 miUrl = '../../Visitas/Visita/CambiarEstadoVisita';

and pass it by ajax

    
answered by 24.08.2016 / 17:15
source
0

You have a bad assistant structure, it should be:

@Url.Action("actionName", "controllerName", new { id = "<id>" });

where (vista,controlador,parámetros(opcional)) is composed, this generates an output in the following way:

 /controllerName/actionName/<id>
    
answered by 24.08.2016 в 16:38