Component reuse between ASP.NET and C # .NET.

This may seem like a funny question since I'm pretty inexperienced with .NET.

Is it possible to build components in C # using .NET that can be reused in ASP.NET. For example, if you want to bring your application to the Internet.

If possible, how portable are they? That is, can the GUI be reusable to some extent? Is there an intermediate format to use as a base, or is it required to use C # components as binaries?

Thank.

Edit:

Thanks for your input! I am very familiar with the design aspects of this problem, i.e. how to model components for reuse. However, you made me realize that the question really is, to what extent is .NET reused between ASP and Windows? Would you say that some of the packages from .NET components are environment independent and some are platform specific?

0


source to share


3 answers


Absolutely - the .NET class can be used in any .NET application. However, it depends on which part of the application you are talking about.

Typically, Windows Forms UIs are NOT reused as ASP.NET UIs because the design constraints are so different (e.g. web browsers only support a small number of controls, often use a flow layout (not grids), etc. Similarly, the events are different (the web form button does not match the window form button, etc.).



Something you can easily use, however, if you do it right, is business logic. Design your classes so they don't know if they are a window form or a web form (or a console app, or a web service, etc.). That is, the classes should be pure implementations of your business logic. Then you can use these classes in any context you want.

+5


source


The short answer to your question is yes, just separate the code you want to split between the two views into an interface independent class, preferably in a separate assembly, and include that assembly.

The long-term answer is the more complex one - the ability to do this will differ between app and app. You will be able to strip less code for UI intensive applications that don't do much behind the scenes (like some kind of graphical game) than for a very simple UI application that has a lot behind the scene (like a UI made up of one button, which then triggers the complex data processing).



At the end - .NET gives you the ability to do this. Your actual ability to do this will greatly depend on your own design skills and your specific requirements. There are a lot of emails out there on this topic - I suggest starting by looking at design patterns (although the original book writes examples in C ++, I believe someone made a book with examples in C #. However, I cannot speak to the quality of it. )

+3


source


I've never done this before, but I think you can put the generic code in a separate class. The UI will need to be duplicated as window forms, and asp.net will be completely delta programming approaches.

+1


source







All Articles