Return view that is in another directory

2

I added a folder inside another folder in the views folder, like this:

  

Views / Registration / Profile

Within the profile folder are the .cshtml files. However, when I try to access the .cshtml files I get an error in the application, I have tried this solution: How to target an Action for a view inside a folder? and I could not solve it, the AP speaks in the end, which I have to create route, but I can not.

My controller looks like this:

public ActionResult Perfil() 
{ 
    var perfils = db.Perfil.Where(p => p.Nome != "Administrador" && p.IDStatus == 1).ToList(); 
    return View("Perfil/"+perfils); 
} 

I get the following error:

    
asked by anonymous 14.10.2015 / 20:22

1 answer

1

In this case, you do not need to change the route to display your view, just return it in your action, like this:

public ActionResult Perfil() 
{ 
    var perfils = db.Perfil.Where(p => p.Nome != "Administrador" && p.IDStatus == 1).ToList(); 
    return View("Perfil/Perfil",perfils); 
} 

In this case, as you just want to return the view, but do not change the route, simply return the Profile view that is inside the Profile folder.

    
14.10.2015 / 21:05