Help on designing a modular ASP.NET architecture

D

Don Huan

Hi

my job is to migrate our WinForms application to ASP.NET. This app was
build very modular so every peace of code can be replaced by another
"modul". There are 1 VS-solution with about 60 projects (dll's) in it.
Now I have to design a Web-Client modul (actually the web-interface). To
maintain the modularity, I thought of making one ASP.NET-Project inside
of the solution and create some projects containing Custom Web Controls.
Did somebody has similar design requirements? Is there any
better/alternative solutions (links)? What is your advice?

Don
 
K

Karl Seguin

60 projects? Wow...that's either a huge system or over-engineered. Anyways,
if your system really is "modular" than your web project should be
incredibly thin. It should be your presentation layer (aspx, html, css,
..js) and very thin presentation logic layer (codebehind, and custom server
controls).

At most I'd suspect that you'd have 3 projects...maybe more if your
application is really different sites. Personally, I'd go with 2, you
should have your raw presentation layer (aspx/html/css/.js and codebehind)
and another project that has your presentation entities (say a "Tab" object
for example) and your custom server contorls - that's it.

Take a look at http://code.communityserver.org/ to see how community server
is organized. Keep in mind that this is there entire presentation, business
and data layer...which you should already have 80%+ in your 60-existing
projects.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
 
G

Grant Merwitz

I think you spot on with your solution.
You don't necessarily have to use controls, but they are nice if there's set
pieces of functionality you want to reuse.

The nice thing about keeping it in the same solution, is that you don't have
to keep referencing your compiled dll's,
as you make changes to your projects it will update the project references
set up in Visual Studio.

I have a project setup similair to the one you are talking - a tad smaller
though - but it works like a charm.
one annoying thing however, may be compile time when developing, you can
ofcourse just rebuild the web project on its own, but when debugging this
may be frustrating.
 
K

Kevin Spencer

Well, Don, it depends on what you mean by "modular." If you constructed your
WinForms application correctly, you separated business logic from UI logic
and code. And if that's the case, you can either re-use the business classes
of your WinForms app (if they are managed), or rebuild them as managed
classes (if they are not), or use Interop to use them (which will engender a
performance hit and some complexity, which I don't recommend offhand). As
for your Custom Controls, anywhere in your WinForms app that you use Custom
Control, create Custome ASP.Net Server Controls to replace them.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Everybody picks their nose,
But some people are better at hiding it.
 
D

Don Huan

Thanks all for quick responce.


Actually every of our modules consists of 3-4 Projects like
- module.buisnesslogic
- module.common
- module.winform

So the requirement is to create one project like
- module.aspnet
for every module.


And that's the reason I can't use UserControls.
My further thoughts are about orginizing css/js and so on in such a big
solution. The aim is to keep web site both modular and simply.
 
G

Grant Merwitz

How come you can't use UserControls.
It's definately a way to modularise a WebSite (i've found), and you can
compile them, and reference and use them across projects.
Hence you could modularise them.

But this sounds like an awfull amout of work.
Considering they will most likely only be used in one solution - the
website,
why not group them all together under one solutiong, in a folder structure
simulating your current modules.
They are, after all, just a UI to your modules, and shouldn't contain too
much functionality as it will be using the code you already have
 
D

Don Huan

ASAIK there's no way to compile and reference UserControls across
projects (like custom controls), or is there one? At least, VS doesn't
provide me the ability to create a UserControl inside of a project other
than WebProject (like in a Web Class Library).
I'm relatively new to asp.net, so sorry for dumb question :)

Don
 
K

Kevin Spencer

It looks like you've built your original project/solution using VB 6. Are
these truly modules you're using? If so, be aware that Modules in VB.Net are
not a good way to go. Use classes instead. While they may not seem as
"convenient" in the short run, they are truly object-oriented (while Modules
are not), and will save you many headaches in the long run.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Everybody picks their nose,
But some people are better at hiding it.
 
G

Grant Merwitz

Not sure about that actually.
I know you can compile them into a dll, but not sure if it can be referenced
like a project reference,
but i can't imagine why not.
 
D

Don Huan

I checked it and there's no way to compile a *UserControl* into a dll
and reference it. That can be done with CustomControls only..
 
D

Don Huan

What is the best way to maintain extern files like CSS, JS and so on? It
would be probably great if they could be placed under their modules
respectively. But how can I then reference them gently from my
CustomControls?

- module_XX
-- CustomControl_xx.cs
-- CustomControl_xy.cs
-- script.js
-- style.css


What are your thoughts about that?

Don
 
K

Kevin Spencer

There are 2 basic ways to approach this. First, an external CSS or JS file,
like a DLL or namespace can be referenced or not in any give page. Second,
CSS can define classes, and is object-oriented. JavaScript is also somewhat
object-oriented, and can be used to define both classes and functions.

We create Custom Controls that are contained in divs. The outer div has a
CSS class, which is used by our graphics designer to design the style and
look of the Control (which has no inline attributes, no tables for layout,
etc, but are "pure" HTML) in any given page context. This allows us to
create Custom Controls that can be "skinned" using CSS classes in external
style sheets.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Everybody picks their nose,
But some people are better at hiding it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top