View previous topic :: View next topic |
Author |
Message |
JackSchitt -
Joined: 25 Jan 2005 Posts: 5
|
Posted: Tue Jan 25, 2005 4:56 am Post subject: [Resolved] VB .Net 2003 Console Mode app as a cgi |
|
|
I'm trying to get this code in a VB.Net console mode app to output some plain text. All I'm getting is 500 Internal Server Error and no entries written to cgi.log
The file is to be named /cgi-bin/CGI-Dev.exe
Any idea as to why this is happening? I would prefer to write this in VB instead of C++ or C#.
Code: | Module Module1
Sub Main()
Console.WriteLine("Content-type: text/plain" & vbCrLf)
Console.WriteLine("Hello world")
End Sub
End Module |
Last edited by JackSchitt on Tue Jan 25, 2005 5:59 am; edited 1 time in total |
|
Back to top |
|
|
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Tue Jan 25, 2005 5:11 am Post subject: |
|
|
You need the VB Developement package to do this , Aprelium sent me a
copy so im posting it for you so you can get it faster than e-mail. LateR!
Note: This is to help you develope CGI using this Visual Basic module
so im guessing this is what you need , can't gurantee it will work. :/
A Visual Basic Module to write CGI applications
http://www.trustabyss.com/vb.zip |
|
Back to top |
|
|
JackSchitt -
Joined: 25 Jan 2005 Posts: 5
|
Posted: Tue Jan 25, 2005 5:31 am Post subject: |
|
|
Thank you very much for that. However, since vb and vb .net are non-compatible, that will not work for me and is not easily translatable.
Instead of writing to streams using the api, there is now direct support for console mode apps in vb .net via the Console object. Considering that you write to the console using the same streams that you write to the webserver with, I was thinking that maybe my configuration was wrong.
I'll try doing it via the and whatnot. I thought that the Console object would be perfect. |
|
Back to top |
|
|
JackSchitt -
Joined: 25 Jan 2005 Posts: 5
|
Posted: Tue Jan 25, 2005 5:43 am Post subject: |
|
|
The code I'm using now is shown below.
The method I'm using now basically emulates the 'puts' macro in c. It aquire an object that references the stdout stream and writes data to the object. Then it flushes that data to stdout.
When running the exe from windows, it open a dos box and outputs the proper text: Code: |
Content-type: text/plain
hello world |
Source code:
Code: | Module Module1
Sub Main()
Dim a As New IO.StreamWriter(Console.OpenStandardOutput(1000))
a.AutoFlush = False
a.Write("Content-type: text/plain" & vbCrLf & vbCrLf)
a.Write("hello world")
a.Flush()
End Sub
End Module |
|
|
Back to top |
|
|
JackSchitt -
Joined: 25 Jan 2005 Posts: 5
|
Posted: Tue Jan 25, 2005 5:59 am Post subject: |
|
|
OK... I had been outputing the compiled application in the wrong folder and running an older one the whole time... Works fine now. |
|
Back to top |
|
|
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Tue Jan 25, 2005 6:17 am Post subject: |
|
|
Im glad you fixed the problem , Have A Nice Day. |
|
Back to top |
|
|
admin Site Admin
Joined: 03 Mar 2002 Posts: 1295
|
Posted: Thu Jan 27, 2005 4:50 pm Post subject: Re: [Resolved] VB .Net 2003 Console Mode app as a cgi |
|
|
JackSchitt,
The explanation: You need one vbCrLf to each CGI header line and an extra vbCrLf to separate the headers from the body. So you need here two "vbCrLf"s. |
|
Back to top |
|
|
JackSchitt -
Joined: 25 Jan 2005 Posts: 5
|
Posted: Fri Jan 28, 2005 1:43 am Post subject: |
|
|
Got the two vbCrLf in there already. Problem was that the output folder for the compiler was set to the wrong folder.
In the original incarnation of the cgi, the one that prompted me to search the forums in the first place, I had neglected the header altogether. I had also copied the exe to the cgi-bin folder, rather than compiled it to that location. Subsequent compilations didn't make it to the cgi-bin folder.
The problem has been fixed, thanks. |
|
Back to top |
|
|
|