650 pts. ASP Content-Type with CGI?

ASP Content-Type with CGI?

What do I type as the content-type in the header within a CGI program. For example an HTML file is text/html ... but text/asp doesn't work. Also, does it change depending on your server? At the moment it just tries to download it as it doesn't recognize the format. Here's the CPP program below (It's the HTTP ... line that is wrong I think):

#include <stdlib.h>
#include <ostream.h>

void main( int argc, char* argv[] )
cout << "HTTP/1.0 200 OK\nContent-type:text/asp\n\n<BR>";
cout << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">";
cout << "<html>";
cout << "<head>";
cout << "<title>Test Page</title>";
cout << "<meta name=\"Author\" content=\"Ben Weeks\">";
cout << "<meta name=\"Keywords\" content=\"?\">";
cout << "<meta name=\"Description\" content=\"?\">";
cout << "</head>";
cout << "<body>";

cout << "<p>Can you read the red text below?</p>";

cout << "<%";
cout << "response.write \"<p><font color='red'>Helloworld!</font></p>\"";
cout << "%>";

cout << "<p>Did you get it?</p>";

cout << "</body>";
cout << "</html>";

Hope you can help.

If you want more points for this question go to "24/11 titled ASP Content-Type with CGI"
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

oliberConnect With a Mentor Commented:
if you need to return an html page, you should use
Content-type: text/html
you do :
 cout << "HTTP/1.0 200 OK\nContent-type:text/asp\n\n<BR>";
first thing to do remove the <BR> at the end.
Second thing, text/asp is no content type,
you should do the following :
let us say that the content that you want to output is in a file called myfile.asp
the good way of doing so would be :
cout << "Location: /myfile.asp\n\n";
and that's it, so when the browser would receive this response, it will then relocate the user to yourserver.com/myfile.asp
and then your file would get executed as a normal asp page.

what happen in you case is that the content you output is sent as is to the user, and the asp ode is not executed (because the browser does not know how to execute asp code - their not here for that)

Hope this helps.
All Courses

From novice to tech pro — start learning today.