This question is a follow up to my question about sharing resources between web applications, because I have not yet found a good solution.
I have a web application with user controls and resources that are shared by three other web applications.
Solution | +-CommonControlsWebApp | +- resources | | +- images | | +- scripts | | +- stylesheets | +- UserControls | +-WebApp1 | +-WebApp2 | +-WebApp3
This is what I know this far:
Can it really be true that ASP.NET does not have a good solution for this? How are you guys organizing large web applications?
Edit: Thanks a lot for all the answers. I am going to copy my user controls with a build event for now, and then see if we have time to refactor them into server controls.
The way we do it at my present company is to make sure CommonControlsWebApp is a WebApplication, not a web site. Then you use names for the folders that would help identify it as the common ones that are distinct from the individual web apps. (CommonUserControls instead of just UserControls)
In your other web apps, you create a virtual directory to the CommonUserControls, etc, and add a file based reference to the CommonControlsWebApp.dll
This requires you to use IIS for development (not casini), and Visual Studio won't believe that the controls really exist, but it will work at runtime, and you can build just fine with only warnings about blahblah.ascx or blahblah.master path invalid.
If you do use common master pages and Visual Studio 2008, you will need SP1 for 2008 and use a __fallback.master in the root of the individual web projects to go in to design mode.
However, I saw this on another thread, and I am going to look into doing more like this: http://webproject.scottgu.com/CSharp/UserControls/UserControls.aspx
You could compile it into a dll
Turning an .ascx User Control into a Redistributable Custom Control
Brief Outline of the Steps
The basic steps to make this happen are as follows:
- Write your user control as you normally would, typically using the Visual Studio designer.
- Test it using a simple page before trying to deploy it.
- Deploy the application to precompile it.
- Grab the user control's assembly produced by the deployment step, and you're essentially done: You have your custom control.
- Finally, use your custom control in other apps
Further info here http://www.nathanblevins.com/Articles/Compile-a-Web-User-Control-into-a-DLL-.Net-c-.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With