Use C # To write a simple CGI program

Source: Internet
Author: User

Use C # To write a simple CGI program

Text: SunWen (From cshrp.net)

In fact, C # can also be used to write programs similar to CGI. It is also very simple to write, that is, to use System. Console. WriteLine. Check the subsequent program:

Class zzz
{
Public static void Main ()
{
System. Console. WriteLine ("Content-Type: text/html ");
System. Console. WriteLine ("<body bgcolor = blue> ");
System. Console. WriteLine ("<center> <p> ");
System. Console. WriteLine ("<B> Hello to everyone. Its me SunWen <B> ");
System. Console. WriteLine ("</body> ");
}
}

We can see that the output of System. Console. WriteLine is in HTML format, and the console is the web server. We just need to compile this file into EXE file, and then put the corresponding CGI-BIN directory in the web server, you can use it. Here, I use IIS as an example to illustrate the problem.

First of all, you must set the site permission to "scripts and executable files". In this way, you can execute the EXE file under the site directory. Copy the EXE file to the site directory and enterHttp: // localhost/a.exeThe result is displayed. Check whether it is an HTML file?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.