Run C# File on the internet like a CGI File - c#

I have a Visual C# project on my computer and I would like my users to be able to interact with it through a web browser. I've done my research, and I understand that I will probably use CGI to do this.
However, while I have been able do this with .pl and .cpp files, i can't figure out how to to it with C sharp (.cs) files. Can anyone explain how I would do this?
EDIT: If there is an alternate solution wherein the webpage communicates my C# program as a back-end program, that works, too.
UPDATE: After cancelling with my hosting provider and setting up a home-based web server (windows), I finally got the C# file to run as CGI. Thanks to everyone for your help!

You've got to give us some context ... why wouldn't asp.net be an option? If you simply don't want to run in the context of IIS, you could simply write a windows service (and expose WCF services, or even raw sockets if that's what you need).
edit: in response to the recent comment about the server being UNIX, you can use MONO to run .net code on that server: http://www.mono-project.com/Main_Page
You can either use something like mod_mono or if you'd prefer something different, you can look at manos de mono

First, I assume you have the Mono project compiler and runtime environment installed on your system.
CGI takes place entirely via standard input and standard output. (This is one reason why it is so easy to write CGI scripts in Perl, Python, Ruby, etc. You just start reading standard input as usual, parse the variables, and write whatever output you want the client to see.) Don't forget that you're responsible for the entire header, including Mime type.
If you need something that performs faster than CGI's constant fork(2)+execve(2) re-starting your CLR over and over again, you can implement the FastCGI protocol (at least, I didn't see a C# implementation on the Wikipedia page) yourself using sockets and start your CLR once only, so you have some reasonable performance. (I seem to remember Nat being passionate about the Mono process start time being "fast enough" to use it for interactive commands, so perhaps a lightly-loaded server won't have any trouble with plain old CGI interface.)

Related

SCP Command in Solaris to file transfer from c#

Is There any way to do following in C#.NET or JAVA,
Get list of files from specific directory of Another pc having solaris OS and transfer file using SCP to another pc which have also solaris OS.
Actually i am thinking about creating front-end in asp.net to transfer backup from Live to backup server and get information about backup.
I even this is possible or not, but I wan't to clear my confusion on this.
Please give me your suggestion.
C# or any other .NET language is specific for Windows and won't run on anything but Windows. So forget about .NET languages. For this type of task I would definitely use Java if you insist on using a programming language at that level.
From Java you can use JSch library. It can do SCP from within Java. Here's is one example.
However I must say that most people that are familiar with Unix/Linux would probably simply do this task from within a scripting environment. Heck it can be done from Bash if you like.
Regardless of your choice of tool/prg.language you'll also have to decide if your doing PUSH or PULL. It seems from your posting that you are most keen on doing a PULL. There's no right or wrong answer on PUSH vs PULL.

C# website, am I forced to use IIS?

I've been thinking for a while about which language to use on my next project. Usually I default to PHP on my LAMP server, but I'd really like to use C# (mainly because of code reuse), and ideally still sicking with Apache. Has anyone used mod_mono on a live project, and if so what is the performance like? The site is likely to get smashed to bits in terms of traffic.
Am I forced to go IIS if I want C#? If not I'll stick to PHP via LAMP as usual.
The answer is "no, one is not forced to use IIS for a C# website". The suggestions above are mostly in alpha/beta development stage however and so using c# for a production website isn't advisable yet.

Wlan information in mono on linux

I am working on a project that will run on a small linux platform. All applications on the system must be written in c# that will be executed via mono. But that is causing me some problems with the network information port. All the examples I have been able to find on the topic on the internet is for .net, and it seems that the WlanInterface module is not implemented in mono.
So the simple question is then, how do I get information such as ssid, rssi, available APs, and its like in mono on linux? Is there a simple way, or do I have to write a service object in e.g. c++ or java to get the information?
damn, not what I was hoping to hear :)
Anyway, I found another solution I will try to pursue. Since the machine has got gnome on it, hijacking the information from the network manager via dbus could be the solution. This might also be a good idea, since I would like to receive an event when connection is lost.
I would still like to hear comments both on this idea, MarkR's idea and any other alternatives.
You can invoke the command line utilities and parse their output via a pipe or something e.g.
iwconfig
iwlist
etc which will ship with a wifi-enabled Linux system.

using c# inside an apache python script

I have a c# application that defines a membership provider used in a Asp.Net MVC application.
And i have an apache httpd server that does authentication with mod_wsgi.
The objective is to share the membership provider between the two, so that the authentication information be the same.
How can i achieve this behaviour ?
Trivially.
Apache serves static content.
Certain URI's will be routed to mod_wsgi to Python.
Python will then execute (via subprocess) a C# program, providing command-line arguments, and reading the standard output response from the C# program.
Python does whatever else is required to serve the web pages.
This presumes your C# application runs at the command line, reads command-line parameters and writes its result to standard output. This is an easy thing to build. It may not be the way it works today, but any program that runs from the command line is trivial to integrate.
Your C# application, BTW, can also be rewritten into Python. It isn't magic. It's just code. Read the code, understand the code, and translate the code. You'll be a lot happier replacing the C# with something simpler.
Several ways:
COM interface (if Windows OS), although this would be a bit slow (make a COM-compatible library, register it with regasm, use it).
Using Gearman (not sure if faster than COM and whether it has Python and C# support, the investigation is up to you) http://gearman.org/
Using the method described by S.Lott
Using SOAP (slow, big)

Filter TCP Packets in C#

I am writing an application where all the request to the internet should go from it like in firewall. so that i can block the request for a particular website. In my case the program will be running on the same machine. I have tried the promiscous method but using that we can only capture all the packets comming and going from the machine,
The easiest way to do it is probably to write a Layered Service Provider (LSP). There is an example in the Microsoft SDK on developing LSPs as well. Not as secure as a driver type firewall setup, but a lot easier to implement.
There's "probably" a way to do it with C#, but I have never tried it. Something to look into. If not then just create a native DLL with C/C++ that implements the LSP then have it communicate with your app.
You have to insert your code in the TCP/IP stack, which, if I understand correctly, requires a windows driver.
C# cannot compile native windows drivers, so you'll need to use a library or DLL to implement at least part of your functionality. Look for solutions using C++.
-Adam

Categories