I'm asking this because I've noticed that in MVC projects, several folders have special meanings ("Controllers", "Views"); when you right-click on them, or on the files they contain, you get access to special menu options, also related to MVC.
But if I attempt to make these folders on, say, one recently generated "ASP.NET Empty Web Application" from VS2010/2012, I don't get these options. It's like either 1)these folders are specially marked for being MVC folders, or 2)the project itself is, as
a whole, marked as a MVC project, so these folders gain automatically that particular meaning.
The thing is, no matter how many times I tried, I simply can't find any significative difference between the .csproj file of the Empty Web Application and the one from a MVC .csproj file.
What am I overlooking here? What makes them different, so much that Visual Studio *knows* that one is MVC and the other is *not* ?
These folders are just regular folders, but the project itself has to be marked as an MVC project. This is in the .csproj file, there's a GUID in there that indicates MVC vs not.
Also, just as an FYI, you don't have put controllers in the controller folder, they can be in any folder even a different project as long as the class name ends in Controller and it inherits from Controller or a derivative of that. The views folder on the
other hand is fixed and mvc expects it to be there because the default view engine expects it there.
Izhido
Member
1 Points
2 Posts
What makes a MVC project file different from a ASP.NET Classic project file?
Aug 03, 2012 08:31 PM|LINK
Hello everyone!
I'm asking this because I've noticed that in MVC projects, several folders have special meanings ("Controllers", "Views"); when you right-click on them, or on the files they contain, you get access to special menu options, also related to MVC.
But if I attempt to make these folders on, say, one recently generated "ASP.NET Empty Web Application" from VS2010/2012, I don't get these options. It's like either 1)these folders are specially marked for being MVC folders, or 2)the project itself is, as a whole, marked as a MVC project, so these folders gain automatically that particular meaning.
The thing is, no matter how many times I tried, I simply can't find any significative difference between the .csproj file of the Empty Web Application and the one from a MVC .csproj file.
What am I overlooking here? What makes them different, so much that Visual Studio *knows* that one is MVC and the other is *not* ?
project mvc classic
CodeHobo
All-Star
18669 Points
2648 Posts
Re: What makes a MVC project file different from a ASP.NET Classic project file?
Aug 03, 2012 08:48 PM|LINK
These folders are just regular folders, but the project itself has to be marked as an MVC project. This is in the .csproj file, there's a GUID in there that indicates MVC vs not.
Also, just as an FYI, you don't have put controllers in the controller folder, they can be in any folder even a different project as long as the class name ends in Controller and it inherits from Controller or a derivative of that. The views folder on the other hand is fixed and mvc expects it to be there because the default view engine expects it there.
Blog | Twitter : @Hattan
Izhido
Member
1 Points
2 Posts
Re: What makes a MVC project file different from a ASP.NET Classic project file?
Aug 03, 2012 09:06 PM|LINK
Aha! There it is, on the <ProjectTypeGuids> tag. Thanks a lot!