ASP.NET MVC View and Controller File Structure

I am very confused in the presentation, and the corresponding controller must be installed in the MVC 1.0 project structure. Currently, in the default application, we have the About.aspx page under the home folder, and all controller actions are processed in the HomeController. This controller mixes the Home action and About action. It makes things dirty. I like to have a clear separation of my controller. As is the case with one controller and HomeCotroller. To do this, I created another "About Me" folder in the browse folder and placed Aboput.aspx in it, otherwise we will get an error below. How can i achieve this? I like to have the exact folder structure, both in the view, just like in Cotroller.

The view 'About' or its master could not be found. The following locations were searched: ~/Views/About/About.aspx ~/Views/About/About.ascx ~/Views/Shared/About.aspx ~/Views/Shared/About.ascx Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: The view 'About' or its master could not be found. The following locations were searched: ~/Views/About/About.aspx ~/Views/About/About.ascx ~/Views/Shared/About.aspx ~/Views/Shared/About.ascx 

I like folders like \ iew \ About.aspx and Cotroller \ AboutController.cs or \ View \ Info \ About.aspx and \ Controller \ Info \ AboutController.cs.

This will make my project and code very clean and easy to maintain. Thanks in advance for your help.

0
asp.net-mvc routing
source share
2 answers

I think they would like you to have

Views / About / index.aspx

which / Views / AboutController Index () points to

Routing Example:

at Global.asax:

 protected void Application_Start() { MyRoutes.RegisterRoutes(RouteTable.Routes); } 

then in the MyRoutes class:

 public class MyRoutes { internal static void RegisterRoutes(RouteCollection routes) { // add routes } } 
+2
source share

You should probably take a look at the basic tutorials for ASP.Net MVC. It works in accordance with several conventions - and one of the biggest conventions is the file and folder name structure.

While the structure you like may be good for simple projects or your personal preferences, it is not ideal for large projects. You need to either follow the convention or learn about the structure so that you can override its behavior.

+1
source share

All Articles