Calling a view in a subfolder

Asked

Viewed 69 times

1

Hello, everybody.

I created a view, inside a subfolder like this example:

Views | Home | Minhasubpasta Myview.cshtml

In the controller, I have the following method that should call this view in the subfolder:

    private ActionResult MinhaView()
    {
        return View("??????"); // <= tem que chamar a view que está na subpasta
    }

I don’t know what to call this view in my subfolder. Some colleague could help me in this matter?

Hugs Hugo

  • Does this controller match the views in the Home? Homecontroller folder?

  • Yes, the method is in Homecontroller. But I did it for now, to exemplify and post my question. In fact, I’ll do it in another custom controller.

1 answer

0

You can do it like this:

return View("~/MinhaSubpasta/MyView.cshtml");
  • Unfortunately it didn’t work. Gave the following error:

  • The view '~/Minhasubpasta/Myview.cshtml' or its master was not found or no view engine Supports the searched Locations. The following Locations Were searched: ~/Minhasubpasta/Myview.cshtml

  • Is the name of the folder and view the same? Myfolder and Myview? It has to be written exactly as in the directory.

Browser other questions tagged

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