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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.