Code Reusability -- Extending web Application

G

Guest

Hi,

This is a code reusability question. I want to include a function that sends an email message from my site. I want to include the code for the function only once and then be able to call this function from any of my pages.

I am aware that there are a number of different solutions to this problem -- user controls and "separate" assemblies are some of them.

What I really want is to extend the Application class (HTTPApplication or HTTPContext -- I am confused as to what does what) to achieve this functionality. In my uneducated terms, I want to open a class definition somewhere in my web project, add a couple of functions, and then be able to access these functions from other pages.

Global.asax and HTTPModules seem to provide this type of functionality for events but how can I do functions at the web application level?

Thanks for your advice.

Zheny
http://www.rusmex.com
 
K

Kevin Spencer

It sounds like you're confused. Your best bet would be to implement a class
library for this sort of reusable functionality.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Hi,

This is a code reusability question. I want to include a function that
sends an email message from my site. I want to include the code for the
function only once and then be able to call this function from any of my
pages.
I am aware that there are a number of different solutions to this
problem -- user controls and "separate" assemblies are some of them.
What I really want is to extend the Application class (HTTPApplication or
HTTPContext -- I am confused as to what does what) to achieve this
functionality. In my uneducated terms, I want to open a class definition
somewhere in my web project, add a couple of functions, and then be able to
access these functions from other pages.
Global.asax and HTTPModules seem to provide this type of functionality for
events but how can I do functions at the web application level?
 
G

Guest

Kevin,

I am new to ASP, so yes, I am confused... There seems to be so many ways in .NET to do the same tasks...

So, you suggest that I compile a separate class assembly and include it in my solution. Then, add references to this accembly from my web project. Did I understand you correctly?
 
K

Kevin Spencer

So, you suggest that I compile a separate class assembly and include it in
my solution. Then, add references to this accembly from my web project. Did
I understand you correctly?

Exactly. A Class Library is a DLL containing classes that can be used by any
other .Net application. In fact, the entire CLR (Common Language Run-time)
is a set of Class Libraries.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Kevin,

I am new to ASP, so yes, I am confused... There seems to be so many ways
in .NET to do the same tasks...
So, you suggest that I compile a separate class assembly and include it in
my solution. Then, add references to this accembly from my web project. Did
I understand you correctly?
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top