Reputation: 127
I'm building a web application using ASP.NET MVC and i have a question about the files organization.
So, i want to create the following structure:
App_Something
Controllers
Views
Models
Areas // I think area is for logic separation.
Private
Controllers
Registers
ProfileController.cs
UserController.cs
OtherFolder
ChildFolder
OtherController.cs
Views
Registers
Profile
Index.cshtml
Create.cshtml
Edit.cshtml
Delete.cshtml
User
Index.cshtml
Create.cshtml
Edit.cshtml
Delete.cshtml
OtherFolder
ChildFolder
Other
Index.cshtml
Create.cshtml
Edit.cshtml
Delete.cshtml
Models
So, i want separate my project files into different folders, but when i do this the viewEngine don't find my views.
First of all... I can separate my project like above? Its, ok?!
for now, this is my code:
Add a route for the controllers actions of Registers folder
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute
(
"Private_Registers",
"Private/Registers/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
context.MapRoute
(
"Private_default",
"Private/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
But, when i run this... The ViewEngine can't find the views into the folder.
I need create a custom viewEngine file with the views locations?
Upvotes: 2
Views: 390
Reputation: 12482
You can do that, but you'll have to render with
Html.Partial or Html.RenderPartial the views path - current location .
Basic structure is
For difference between Html.Partial and Html.RenderPartial look here
Upvotes: 0