Best practice for using a user control across many projects

asp.netdryuser control

I have a messaging User Control, that is used across 4 projects, and for each change I have to propagate it in 4 places. This is obviously against the DRY principle. However, centralizing user controls is not an easy task too, because you have both markup, and code-behind, and we know that markup won't get compiled till run-time requests. This means that you can't simply put the User Control in one project, and compile it, and use its result DLL file in many places.

So, what do you suggest as a good, neat approach for centralizing use of User Controls?

Best Answer

Create a NuGet package for it. You should be able to deploy the markup and code behind to the appropriate locations as well as handle any web.config changes, and manage updating all of this as a unit, with a NuGet package.