Redirect to View in another structure

Asked

Viewed 1,373 times

3

I have a project, which is in an area, in it, my Main controller, has an action that, when called, should return a view that is in another folder, however, within the same area.

return View("OutraPasta/Index.cshtml");

return View("~/Views/OutraPasta/Index.cshtml");

return View("~/Views/Area/OutraPasta/Index.cshtml");

but none of the options actually returns this view.

  • What is the purpose of this?

  • 1

    Redirect to another view, Ué...

  • But why another directory within the same area? Why can’t the View template be in the same directory?

  • Because each module needs to be in its own structure. But the view you require is in the main structure. And the responsible person wants to see in the views the folders of the modules. This is the case? = T

  • Yes, the area has this objective: to offer its own structure, as a module, detached from the main structure. Maybe you are incurring a bad practice.

1 answer

4


There’s no mystery, just use the full view path.

return View("~/Areas/NomeDaArea/Views/NomeDaView.cshtml")
  • It did not shine. It will be some route problem?

  • This has nothing to do with routes. Make sure the call falls correctly in the controller?

  • Yeah. There’s a bp there.

  • And this view is in some area or it is at the root of the application?

  • It worked perfect. I missed the: Views/ in the middle of the way. Thank you, jbueno. (=

Browser other questions tagged

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