How do I direct an Action to a view inside a folder?

Asked

Viewed 721 times

1

In my Ugcontroller I have an Action named Register that takes me to the View Register.cshtml that is in the UG folder.

That is to say:

Controller: UGController
Action: Cadastro()
Link: /UG/Cadastro
View: /UG/Cadastro.cshtml

Until then normal. But I would like to create a folder inside the UG View to put another file

Controller: UGController
Action: ?
Link: /UG/PDF/Lista
View: /UG/PDF/Lista.cshtml

Doubt: How to get Action to take me to the.cshtml List with the link I described?

2 answers

1


Use:

return View("caminho/para/sua/pasta/NomeDaView");

For example:

Controller: MyController
Action: MyAction
Link: MyController/MyAction
View: Views/MyController/PastaQualquer/MyAction


public ActionResult MyAction()
{
   return View("PastaQualquer/MyAction")
}

If you don’t resolve on return View(""), will have to create a new route.

0

In your case I’d be:

return View("UG/PDF/Lista");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.