sistemas distribuídos
Archived Posts from this Category
Archived Posts from this Category
If you want to use C# to write CGI applications, you might stumble on some technical difficulties, when using the IIS web server: no matter what are the permissions you set for the folder holding the CGI executable, whenever executing it, the web server doesn’t process the file and tries to serve it as if the client had requested its download!
One workaround is to explicitly map some dummy extension, to the EXE that you want to use as the CGI application.
For example, map “.CSX” to the executable that is the output of your C# CGI solution.
The HTML that needs to invoke the CGI, must invoke the dummy (zero bytes) .CSX file, because invoking the .EXE would produce the IIS problem already mentioned.
In order to do the “.CSX” <—> “CGI.EXE” mapping, (1) create one server side directory (virtual or not) to hold the C# CGI solutions.
The picture below shows that, in some computer, the “\cgi-bin\cgi_cs” folder was chosen to hold the C# executables.

After (1), make sure that you (2) create an “IIS application” for the folder, having execute permissions for BOTH script and executables.

Once the application is created, it is possible to configure it. So, (3) click the configuration button.

(4) The relevant tab in “application configuration” is the “mappings” tab. Here, click the “Add” button. This operation is the way to build the aforementioned “.CSX” <—> “CGI.EXE” relation.

(5) In the “mapping” dialog, browse to the C# .EXE file that is intended to run as a CGI; then type “.CSX” as the extension; then you can uncheck the “check that file exists” option and, finally, press the OK button.
If the OK button is dimmed/grayed/not enabled, just click once on the executable textbox!

(6) After this, the “application configuration” dialog box should list the “.CSX” extension at the bottom.
In order to use the new mapping, restart (stop, then start) the IIS web server.
Having done these six steps, all that is left is to code the right invocation of the CGI. For example, if using forms and its action attribute, point the action to some empty .CSX file.
To build an empty CGI.CSX file, go to the “command prompt” and type “copy con cgi.csx”, followed by ENTER, followed by CTRL+Z (which is the end-of-file character).

0 comments Wednesday 29 Nov 2006 | am | .NET, dev, distributed systems, edu, inet, inet tech, sistemas distribuídos, sistemas web, web systems