Where should I put my data with the exact display of asp.net-mvc?

I inserted my viewdata classes inside my controllers, and as their numbers grow, I start asking myself if this is a good idea. Again, something about polluting the / Views and / Controllers directories with these things seems to be turned off.

Is there an agreement I'm missing here? Maybe the directory / ViewData? idk, what are some good places for my viewdata classes?

+6
conventions asp.net-mvc
source share
4 answers

I did exactly what you offer, I have my own strongly typed views living in / ViewData. I thought about putting it in the \ Model directory, but I don’t like my projects with too many nested directories. \ ViewData is also Kigg .

0
source share

I do not know the agreement. I just placed mine under /Model/ViewModel/BlahViewModel.cs etc. I would not put them in a separate project until there was a definite need for this. If necessary, it would not be easy for them to move them later.

+3
source share

I put my presentation data classes in a project dedicated to just that. This is a DTO, and their inclusion in their own project provides that they are not dependent on anything higher in the architectural layers.

Using them as DTOs for presentation as representations is just one way to use them. I can send them through the wire for a while, inside the message on the service bus or something else.

0
source share

since you are using MVC, and the folder structure should represent the namespace structure of your code that I would recommend for each of your object domains, you must group the controllers, models, and services into separate folders

we would use

  • Domainname

      Controllers Model Services 
0
source share

All Articles