ASP.NET Versioning, Folders or Solutions

As the title reads I was wondering if when I introduce versioning to my REST API, if i should use version folders (like a v1, v2, v3 folder in my Controllers root folder) or if i should make seperate solutions in 1 project for versioning and how much sense that makes, considering this will be a very large scale project
4 Replies
Pobiega
Pobiega2mo ago
First question is how you plan to version your apis. You could version each endpoint individually, which is what I usually prefer myself, or the entire api as one big thing. For option 2, you need to consider what to do with an endpoint that had to changes between version X and X+1. I'd probably advise against creating a separate project for each version however a folder for each is more than enough also, come up with a plan for deprecation and version removal. Maintaining and supporting 5 versions of the same endpoint is a nightmare scenario
The Fog from Human Resources
My thought process on seperate solutions in 1 project was about Being able to have shared logic and a better way to maybe isolate different data models between versions :thinker: I'd probably version the whole controllers
Pobiega
Pobiega2mo ago
are you mixing up what a solution and a project is? :p a solution is a collection of projects. you can isolate models etc with a namespace. The problem with having your controllers be in different projects means its a bit more complicated registering your controllers, and it might get a bit nasty when you have a lot of versions to see 50+ projects just for your controllers... so I'd recommend a more VSA style architecture.. something like.... (1 sec)
.
└── features/
└── AddItem/
├── . // reusable components that are not versioned go here
├── V1/
│ ├── AddItemControllerV1.cs
│ └── . // dtos, etc go here
└── V2/
├── AddItemControllerV2.cs
└── . // dtos, etc go here
.
└── features/
└── AddItem/
├── . // reusable components that are not versioned go here
├── V1/
│ ├── AddItemControllerV1.cs
│ └── . // dtos, etc go here
└── V2/
├── AddItemControllerV2.cs
└── . // dtos, etc go here
The Fog from Human Resources
Ah yes, I meant project then my mad I will probably go for an approach like this then, from what it looks like it will pretty much do what I want I'm gonna leave this thread open for a bit longer until I implemented it into a test project, thank you!

Did you find this page helpful?