Palani
Palani

Reputation: 9042

Grouping View File along with Controller File

In WinForm and WebForm Application, Visual studio groups the 'View' File and 'Contorller' File, together. I found very easy to manage file in that way.

Now in ASP.Net Mvc , i'm finding difficult to manage views, separately in completely different folder.

Is there any way to group View and Controller files in VS Solution Explorer, like we used to do in WinForm and WebForm Application ?

alt text

Upvotes: 1

Views: 178

Answers (2)

Jarek Kardas
Jarek Kardas

Reputation: 8455

you can use VSCommands to group/ungroup files directly from Visual Studio

Upvotes: 1

Filip Frącz
Filip Frącz

Reputation: 5947

I think they did that on purpose - views should be independent from controllers. Think of it like this: you should be able to put controllers into a totally different assembly and still have your application work. Your controllers should also be able to work with totally different set of views.

The framework is also setup to go to the views folder to fetch appropriate files. You would have to change that behavior yourself if you decide to move the views. Might not be worth the hassle.

And finally, if you really want to do it, you should probably look at your project file. There is a DependsUpon element that you can use to make a file go underneath another:

<Compile Include="Form1.Designer.cs">
  <DependentUpon>Form1.cs</DependentUpon>
</Compile>

Upvotes: 3

Related Questions