How to start ASP.Net application from console application?

M

Mike

Hi,
I have the following problem:
I have a singleton class that I want to access from asp.net
application. The trick is, that I want to create it
(Singleton.GetInstance() for the first time) in console application.
In other words, I want the following to happen:
1. start console application
2. create object
3. start asp.net and pass the object reference
4. after some time, user surfs to asp.net page, and sees some
properties assosiated to that
object.

Can I accomplish that without using 2 processes (console and asp.net)
and .Net remoting between them?

Thanx alot,
Mike
 
R

Robbe Morris [C# MVP]

Why would you want to do this?

As a side note, you might want to consider
creating a .NET webservice and have your
console app pass the object in as a parameter.

Your web service for that application can
decide what to do with it in the context of
ASP.NET.
 
M

Mike

Let me explain why I want this.
I want my singleton to be independent of the asp.net webserver.
The webserver might run, or stop running, but it shouldn't interfere
with the singleton.
In the same time I want the webserver to know my singleton as a local
object.

I didn't understand your webservice suggestion. Webservice
communication is done by exchanging xml messages, and thats not what I
want. I want my asp.net webserver
to have a local reference to singleton object.

Thanx alot,
Mike
 
R

Robbe Morris [C# MVP]

Hmmm. What exactly does the singleton object do
and what does it hold? Perhaps there is an
alternate solution to a singleton that completes
the task you are after.

Your app can be recycled and still maintain state
by using StateServer. You could also run this
across a web farm using a product like
ScaleOut Software's StateServer:

http://www.eggheadcafe.com/articles/scaleout_server.asp

I don't think you can reliably do what you are wanting
to do. Plus, your app wouldn't scale to a server farm.
You don't generally want to design yourself into
a corner like that.
 
R

Rick Strahl [MVP]

Are you talking about controlling the ASP.NET application?

You can host the ASP.NET application as part of your Console application and
then communicate with it if you need to via AppDomain Remoting...

ASP.NET Runtime Hosting:
http://www.west-wind.com/presentations/aspnetruntime/aspnetruntime.asp


Otherwise, if your app is not in control of hte ASP.NET hosting process (ie.
IIS or the ASP.NET Local server) there's no way other than some sort of
remote connectivity between processes (using Remoting or Web Services or
File Sharing or whatever).

+++ Rick ---

--

Rick Strahl
West Wind Technologies
www.west-wind.com
www.west-wind.com/weblog
 
M

Mike

Hi,
thanx Rick for the informative article you provided.
The only question that is still hangs unanswered for me, is whether
there is a real difference between remoting between two appdomains, and
remoting between two processess.

The only difference I can see between the two scenarios, is that in the
scenario of two appdomains, console app will be able to shutdown
asp.net, before exiting.
In the " two processess", asp.net webserver is going to run absolutely
independently of the console application.

Am I missing something?

Thanx a lot,
Mike
 
M

Mike

My singleton is some network service, that accamulates information that
flows from the network. The asp.net webserver accessess the singleton,
in order to reflect that
accamulated info for clients, that browse to a certain page in the
server.

Hope I made myself clear enough.

Thanx,

Mike
 
R

Robbe Morris [C# MVP]

Why aren't you using a database store for this information?

What happens when the console app dies? How
are you persisting that data?
 
M

Mike

I am not interested in persisting, because this is "real-time" info,
that is not intrested to my clients
even 1/2 afterwards.
If console app dies, clients won't be able to connect and see the info
- and thats OK. Thats what I want.

Mike
 
R

Robbe Morris [C# MVP]

You could write a windows service that opens up
and listens on a tcp socket. Then, you could
either simply connect to the tcp socket
on page load "or" using a client side ActiveX
control that can connect up to the tcp socket.

Perhaps Macromedia Flash...

You could also look into message queues.
The console app writes a message to the queue
and the asp.net application could read from
that whenever needed.
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top