Running multiple sites from one ASP.NET database and migrating to ASP.NET MVC

I have a fairly large project at work that I have inherited. This is an ASP.NET 2005 website project and two C # library projects for accessing data and some business logic. The code actually runs 6 different database-based websites. It displays different images and text for each site based on logic that parses the URL and uses a series of Web.config values ​​and switch statements.

We now have several new websites that will follow the same pattern and structure as these 6, and therefore the management decided that we should not reinvent the wheel, and we should continue to extend the existing code. Although I understand the solution from their point of view, the idea of ​​extending this code with even more Web.config values ​​and even more switch statements still seems wrong. There seems to be a better way to manage this particular form of complexity, but I have no way to deal with what the best way should be.

At the same time, I was looking for a project to start exploring ASP.NET MVC, and I tend to re-develop this project with it in due time, because it is complex, but the requirements are in the code. I am looking to get 3 things from moving it to MVC: 1) to be able to test the application and all its versions, and all its dark angles that I don’t even know about, there are still, 2) I hope to find a way to make the control about 12 sites on one managed code base; and 3) the study of MVC.

After a few, here are some specific questions:

Will MVC offer me the best ways to manage 12 sites in the same code issue? It’s a little difficult for me to tell without a deeper knowledge of MVC.

Is there a template template or framework that I can apply (in WebForms or MVC) that is suitable for sites that have similar content and structure and work with the same code base?

Is there a better way than to examine the URL to determine which site is being viewed, and which images and text should be displayed for each site?

Thanks for the time. I appreciate it!

+4
source share
2 answers

ASP.Net MVC may have some real benefits for you here. You will no longer manually examine the URL, because the MVC routing function will do this for you, so in a sense this is the “best way”. Here are some benefits:

  • URL routing is an easy way to distinguish which site is being served, and the "some site I" parameters are automatically passed to each controller (and then to each view) if you structure your routes correctly.

  • URL routing works in both directions, so it would be relatively easy to define a single view for all of your sites on which the correct images were created, and script links to any site directory you needed.

  • Partial views would be a great way to switch site content in corner cases where the template was not exactly the same for each site.

While the logic was fairly similar for each site, ASP.Net MVC 1.0 could handle this. If you need different controller logic for each site, in the upcoming version of ASP.Net MVC there is a concept of "areas" that will allow you to implement different sites in one application, all of which have their own directories Controller, Model and View - but have been differentiated by their routes.

+1
source

Will MVC offer me the best ways to manage 12 sites in the same code issue?

Honestly: I would not go down this road. ASP.NET is powerful enough to have a tiered system. There are things that help you create reusable applications in ASP.NET MVC. You have an IoC for changing business rules between applications, and you have the ability to dynamically choose which type of rendering. You have testabillity.

Everything is fine: read here about it like this

But still: This is a huge attempt to implement such a system. ASP.NET is wonderful (now you have Routing!), And if you have a working system, better invest your time in improving it.

+1
source

All Articles