How to start ASP.Net application from console application?

Discussion in 'ASP .Net' started by Mike, Nov 27, 2005.

  1. Mike

    Mike Guest

    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
    Mike, Nov 27, 2005
    #1
    1. Advertising

  2. 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.

    --
    Robbe Morris - 2004/2005 Microsoft MVP C#
    http://www.masterado.net





    "Mike" <> wrote in message
    news:...
    > 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
    >
    Robbe Morris [C# MVP], Nov 27, 2005
    #2
    1. Advertising

  3. Mike

    Mike Guest

    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
    Mike, Nov 27, 2005
    #3
  4. 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.



    --
    Robbe Morris - 2004/2005 Microsoft MVP C#
    http://www.masterado.net





    "Mike" <> wrote in message
    news:...
    > 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
    >
    Robbe Morris [C# MVP], Nov 27, 2005
    #4
  5. 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

    "Mike" <> wrote in message
    news:...
    > 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
    >
    Rick Strahl [MVP], Nov 28, 2005
    #5
  6. Mike

    Mike Guest

    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
    Mike, Nov 28, 2005
    #6
  7. Mike

    Mike Guest

    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
    Mike, Nov 28, 2005
    #7
  8. Why aren't you using a database store for this information?

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

    --
    Robbe Morris - 2004/2005 Microsoft MVP C#
    http://robbemorris.blogspot.com





    "Mike" <> wrote in message
    news:...
    > 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
    >
    Robbe Morris [C# MVP], Nov 29, 2005
    #8
  9. Mike

    Mike Guest

    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
    Mike, Nov 29, 2005
    #9
  10. 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.



    --
    Robbe Morris - 2004/2005 Microsoft MVP C#
    http://robbemorris.blogspot.com





    "Mike" <> wrote in message
    news:...
    >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
    >
    Robbe Morris [C# MVP], Nov 30, 2005
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert Wehofer

    Start console application with arguments

    Robert Wehofer, Nov 10, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    391
    Robert Wehofer
    Nov 10, 2003
  2. Web learner
    Replies:
    1
    Views:
    1,604
    =?Utf-8?B?Q2hhc2U=?=
    Jan 27, 2006
  3. chad
    Replies:
    1
    Views:
    3,683
  4. Ben Finney
    Replies:
    2
    Views:
    987
    Egor Bolonev
    Jun 30, 2003
  5. Egor Bolonev
    Replies:
    0
    Views:
    477
    Egor Bolonev
    Jun 30, 2003
Loading...

Share This Page