ASP.Net MVC View and Controller file structure
- by Jit
I am very confused the View and corresponding controller has to be set in MVC 1.0 project structure. Currently in a default application we have About.aspx page under Home folder and all the controller action is handled in HomeController. This controller mixes up Home action and About action. It makes things messy. I like to have clear separation of my controller. Like to have one About Controller and HomeCotroller separately. For it I have create another folder "About" under view folder and place Aboput.aspx in it , otherwise we will get the error below. How can I achieve it ?? I like to have exact folder structure as in View, same as 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 to have 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 cleanly placed and good to maintain.
Thanks in advance for helping