views:

71

answers:

3

Hi, I've a general design question:

I have a mailserver, written in C#.
Then I have a web forum software, written in for ASP.NET in C#.

Now I'd like to integrate the mailserver into the ASP.NET forum application. For example, I'd like to make it possible that one can create a mailinglist from the forum, and give users the oportunity to add oneselfs to the mailinglist members in the forum, and then add the new list-members to the respective mailinglist on the server.

Since the server is a separate console/winforms/service application, I first thought I'd best use .NET remoting for this.

But my second thought was, that some users might host their forum on a host where
(a) they don't have a virtual machine where they can do what they want
(b) the admin of the host might not want to install an additional mailserver or charge extra for this
(c) the user might have a service plan that only permits to add a web-application, not external programs (very likely)


Now, I wanted to ask:
Is it possible to fully integrate a mailserver into an ASP.NET application somehow ? (I have the full source of the server + ASP.NET application)

Well, it probably won't be a page or a ashx handler, but something like a http module ? Or what's the general way to integrate TCP/IP applications into asp.net ? (Of course I'm assuming the respecive ports are available/forwarded - and I'll make it possible to also run it with the e-mail server as external application)

A: 

It's probably not a very great idea, but you can start a thread in Global.asax and do background processing while the application pool is running/the web app is not reloaded. So you could start your server there, but you have no control over the lifetime of it

chris166
A: 

Adding to chris166's comment... you also wouldn't get control over when the application is started. [Since the application won't be loaded until a page is requested...] Its probably a better idea to setup some sort of integration between the web app and the console/service app.

I'd probably tend towards setting up a near-realtime integration where the mailserver polls the forum app for requested changes.

joe.liedtke
Well, I'd just have to request a page myself after every restart. Well, true, if I'm not the admin, then I have no control over that, neither - since I wouldn't know when, if, and how many times the server gets restartet. But why polling? The forum application would send changes to the server immediately via .NET remoting. No need for polling. But the better question would be how long would the server remain running. That is to say, will the webapp get garbage-collected after some specified time.
Quandary
In part its my preference... I am working under the assumption that you have little control over the environment that the web app is deployed to.. in that case a web service API seems like the most reliable/simplest way to implement the integration. If I recall correctly IIS can host remoting apps, but I'd probably lean towards web services...
joe.liedtke
+1  A: 

In the ideal case I'd do the following:

Set it up on your own server(s) and expose a WCF/web service that your web app will/can interact with.

If you can't or don't want to afford to keep it running on your own, you could then charge a subscription fee for it.

SnOrfus
Actually, that's a very good idea. I charge for the forum. Then I charge again for the mailinglist. Or I append adds to the mailinglist-mails.
Quandary