Web Interface for a c# Console Application

  • Thread starter Thread starter viashino
  • Start date Start date
V

viashino

Hi,

I have written a Console Application that is doing different things,
like checking the status of different network Hosts.

I would like to implement a WebInterface to show such status, and maybe
also send some commands to my app.

It is possible to do it in asp.net ? I though I only need to "pass" my
object reference to the ASP page, so I can access its proprieties...
But I don't know how to do it (and if it is possible).

I saw lots of threads about WinForms to WebForms, but none about
ConsoleApp to Web.

Any link would be very appreciated.
Thanks

Viashino
 
Hi there

By the sounds of things, all your logic is in the console app.

What you could do is put all of this in a class library and the use the
console or asp.net as the ui layer

Sam
 
Thank you for the answer.

Indeed the logic is in the console app, since this program needs to run
24/24.

I don't know if putting it in a class library would work, since I need
to access the objects, and not the classes.
I think that putting it in a class library means only exporting the
classes... Am I wrong? (class library is pretty new to me).

Can you please add some link?

Thanks

samuelhon ha scritto:
 
Hi

If this is the case then a console app is the wrong kind of app, you need
either a win service or a web service, the later is my suggested way to go.

Or simply you could implement a web app around it
 
Well, I couldn't use win service, because it would run also on Linux.

About web service, I found something (gooogling a lot), and was
thinking about it.

But I have a problem with both web services and remoting (that was
another option I found).

When I try to compile I get that it can't find the namespace "Services"
inside System.Web.
I downloaded different pieces of codes and always get the same error.
Also I "don't have" Channel.Tcp (for remoting)...

Do I need additional packages?
I have .Net v2.0.50727

Thank You for your answer.



Ignacio Machin ( .NET/ C# MVP ) ha scritto:
 
Hi,

Thank you for the answer.

Indeed the logic is in the console app, since this program needs to run
24/24.

If an application must run 24/7, the best would probably be a windows
service, but I leave that to you. Actually, any kind of application may
run 24/7 (if programmed with care, and accepting a perfect stability),
so this specific requirement does not necessary lead to a console
application.

Additionally, even if the application itself is a console one, it can
still use a class library. A clever design would put all reusable code
in a class library (a DLL), and keep the UI (or in your case the console
app) as thin as possible. This way the cost of migrating an application
from Windows to the web is very small.
I don't know if putting it in a class library would work, since I need
to access the objects, and not the classes.

Classes and objects is (almost) a synonym. "Class library" is just a
name, don't read too much into it.

To create a class library, simply choose the according project type in
Visual Studio. Then you can move all the classes you want into that
project. Then add a reference to that project (or to the produced DLL,
but that's not recommended) into your console application. From this
moment on, you can use the classes as if they were in the same project.
I think that putting it in a class library means only exporting the
classes... Am I wrong? (class library is pretty new to me).

Can you please add some link?

Thanks

HTH,
Laurent
 
Not sure why you are having these issues.
I have written a web app that allows control of remote devices via remoting
to a windows service.
The win service knows how to communicate with the devices.
The Web App provides a web based 'live' interface to said devices.
The Web App communicates with the win service via remoting.

Gerry
 
unless you are talking static on a single machine there is a huge difference
between a class and an object.
2 processes making use of a single physical object is entirely different
than 2 processes making use of 2 seperate objects of the same type.

Gerry


Laurent Bugnion said:
Hi,

Thank you for the answer.

Indeed the logic is in the console app, since this program needs to run
24/24.

If an application must run 24/7, the best would probably be a windows
service, but I leave that to you. Actually, any kind of application may
run 24/7 (if programmed with care, and accepting a perfect stability), so
this specific requirement does not necessary lead to a console
application.

Additionally, even if the application itself is a console one, it can
still use a class library. A clever design would put all reusable code in
a class library (a DLL), and keep the UI (or in your case the console app)
as thin as possible. This way the cost of migrating an application from
Windows to the web is very small.
I don't know if putting it in a class library would work, since I need
to access the objects, and not the classes.

Classes and objects is (almost) a synonym. "Class library" is just a name,
don't read too much into it.

To create a class library, simply choose the according project type in
Visual Studio. Then you can move all the classes you want into that
project. Then add a reference to that project (or to the produced DLL, but
that's not recommended) into your console application. From this moment
on, you can use the classes as if they were in the same project.
I think that putting it in a class library means only exporting the
classes... Am I wrong? (class library is pretty new to me).

Can you please add some link?

Thanks

HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
 
Hi Gerry,
unless you are talking static on a single machine there is a huge difference
between a class and an object.
2 processes making use of a single physical object is entirely different
than 2 processes making use of 2 seperate objects of the same type.

Gerry

You are absolutely right. The apparent confusion in the OP's post got to
me too.

Greetings,
Laurent
 
Hi,

Well, I downloaded Visual Studio Web Developer, and now I can run
WebServices (didn't tried remoting). Now I'm going to implement the
WebService into my code to export some methods of my objects. It should
work... I suceed in a "hello world" WebService so its just a question
of time :D

Thanks for answering.
Viashino

gerry ha scritto:
 
Indeed the logic is in the console app, since this program needs to run
service, but I leave that to you. Actually, any kind of application may
run 24/7 (if programmed with care, and accepting a perfect stability),
so this specific requirement does not necessary lead to a console
application.

Additionally, even if the application itself is a console one, it can
still use a class library. A clever design would put all reusable code
in a class library (a DLL), and keep the UI (or in your case the console
app) as thin as possible. This way the cost of migrating an application
from Windows to the web is very small.

This is the way to go. Put all core logic in the class library and then
use different UIs (console, web or windows) to control/view responses.

I would suggest working on this first (using the console to test)
before worrying about web or windows services

Sam
 
Back
Top