Trigger action in C# executable from web application

P

Passiday

Hello,

We have this web application (it's developed in C#, but that really
does not matter), and part of it's functionality is to print some data
on a specific kind of printer that's attached to the user's PC. The
printer will print if a file to print is placed in specific configured
folder in the PC's local file system. So the web app that resides in
the browser, pretty ignorant about the PC where it is running on,
needs to trigger a local process that will result in the file created
in the needed place.

Right now we go with rather heavy solution - a local webserver is
installed and the web app passes the data to local URL, and the tiny
script does it's thing - collects the data and creates the file in the
needed place.

I am now wondering if we could set it up in more elegant way:
1) Have a local C# app triggering regularly far web server "is there
anything for printing".
- pros: seems simple to implement
- cons: regular far webserver triggering sounds like bad architecture.
Also delays could be a problem.
2) Have a local C# app that acts as simple http server
- pros: sounds like the most direct way to pass down info to local app
from the browser
- cons: potential security problems? Could be complex to develop?

Maybe there is some other smart idea how a local process can be
triggered from a web app?

Passiday
 
P

Peter Duniho

Passiday said:
[...]
I am now wondering if we could set it up in more elegant way:
1) Have a local C# app triggering regularly far web server "is there
anything for printing".
- pros: seems simple to implement
- cons: regular far webserver triggering sounds like bad architecture.
Also delays could be a problem.
2) Have a local C# app that acts as simple http server
- pros: sounds like the most direct way to pass down info to local app
from the browser
- cons: potential security problems? Could be complex to develop?

Maybe there is some other smart idea how a local process can be
triggered from a web app?

Why does it have to be a local process other than the web application?
Can a web application not print? I see Javascript-based pages print all
the time (or at least, invoke the print dialog so the browser can
print). And I've seem web applications that can download and save files
to my computer, so how is it that your web application cannot be
designed to somehow place a file in the correct place?

(These are rhetorical questions...I don't personally need an answer to
them, I'm just asking them as a way of prompting some thought along
those lines).

It seems to me that you really should be asking your question in a
newsgroup where questions about web applications are specifically
on-topic. There you may find advice from someone who knows how your web
application can directly handle the printing needed, rather than using
an independent process the web application needs to communicate with.

Barring that, certainly I'd agree that having a local program with which
the web application can communicate directly is much better than having
the web application notify a remote server that the local program is
polling on a regular basis.

As far as security problems go, I suppose it's true that any time you've
got a process running that can accept data from an external source,
there's a potential for issues. But using .NET, hopefully the biggest
threat would be some kind of denial-of-service or abuse-of-service, and
if you accept requests only from local IP addresses, that should be
minimized.

If I were you, I'd post my question to a more relevant newsgroup, and
see if there is better advice from people actually writing web
applications on a regular basis, including the possibility that someone
can explain to you how to get the printing to work without a separate
process at all.

Pete
 
A

Alberto Poblacion

Passiday said:
[...]
2) Have a local C# app that acts as simple http server
- pros: sounds like the most direct way to pass down info to local app
from the browser
- cons: potential security problems? Could be complex to develop?

This is easy to develop if you download the code for the Cassini web
server, which you can add to your project and compile together with your
application:
http://www.microsoft.com/belux/msdn/nl/community/columns/desmet/hostaspnet2.mspx

The original Cassini only accepts connections from the local machine,
buut since you have the source code you can search the one line where it
performs this check and remove it. Or better yet, change it so that it only
accepts connections from your web server; this should alleviate some of your
security concerns.
 

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

Top