500 Error: Unable to process request, CGI script failed to generate a response (Domino Web Server)

Hi,

I’ve created a small CGI script for testing as I need some dynamic content on Domino, and I’m learning how to use CGI.

When I try to execute the script using the following URL:

http://server/cgi-bin/testcgi.exe

I get this error from Domino:


Http Status Code: 500

Reason: Unable to process request, CGI script failed to generate a response


It sounds to me like it’s not picking up the response header, however I am sending it and with two returns at the end of the header. Here is the code I am using, it’s in VC Express 9 using the Win32 Console Application template, sorry about the lack of tabs:


#include “stdafx.h”

using namespace std;

int main()

{

string Output;



Output += "Status: 200 OK\n";

Output += "Content-type: text/html\n\n";

Output += "<html>\n";

Output += "<head>\n";

Output += "<title>CGI Test</title>\n";

Output += "</head>\n";

Output += "<body>\n";

Output += "<h3>Matt's CGI test!</h3> Test Loop: <br>\n";



for(int i = 0; i < 10; i++)

{

	Output += "<b>Loop ";

	char pos[256];

	sprintf(pos, "%i", i);

	Output += pos;

	Output += "</b>\n";

}



Output += "</body>\n";

Output += "</html>\n";



cout << Output.c_str();



//system("pause");



return 0;

}


What would be causing this? There’s this ancient executable on our server which seems to work fine, I’ve used the command line to cross reference that with mine, and I can’t see what it’s doing that mine is not… so I guess it isnt the output, and our server must be configured properly…

Subject: 500 Error: Unable to process request, CGI script failed to generate a response (Domino Web Server)

Ok, I have managed to fix the problem.

For anyone who has this problem, the solution is to go to your Project Properties and under C/C++ >> Code Generation, and change the Runtime Library option to “Multi-threaded (/MT)”, my project was defaulting to the DLL which will not work with Domino.