The Power of C#: A Server Side Program
| I have developed a very simple server side program which shows thepower of the C#. This is a table program requires IIS installed on themachine in order to check. The User entered the table number in theform and then press Submit button. The action of the form will call theC# application and that application disect the QUERY_STRING into thestring parameters. All the important things one should have to do inthe server side coding is to get the parameters from the Query string.After getting the string, you can convert it into an interger and canthen use it in your table program. To generate HTML page, dont forgetto write the Content-Type:text/html in the WriteLine. |
namespace Net2
{
using System;
// <summary>
// Summary description for Class1.
// </summary>
public class Class1
{
public Class1()
{
//
// TODO: Add Constructor Logic here
//
}
public static int Main(string[] args)
{
//
// TODO: Add code to start application here
//
try
{
//Get the Environment Variabel
he he
string t;
t=System.Environment.GetEnvironmentVariable ("QUERY_STRING");
string[] u;
char[] v = new char[1];
v[0] = '=';
u = t.Split(v);
//Convert the string into an Integer, thats a trick
ushort a = u[1].ToUInt16();
//Shows in the browser, send the output to the browser
Console.WriteLine("Content-Type:text/html\n");
Console.WriteLine("<H1>Table Program</H1>");
//calculations
int res;
for(int i=1;i<=10;i++)
{
res = a * i;
Console.WriteLine("<br> " + a + " x " + i + " = " + res);
}
//Console.WriteLine("<i><br><hr>Completed</i>");
Console.WriteLine("<hr><br><b>This Program is created By Furqan Ullah Using C# Beta Compiler</b>");
Console.WriteLine("<i><br>For Questions and Comments: </i>");
Console.WriteLine("<a href=mailto:furqan@writeme.com><i>furqan@writeme.com</i></a>");
}
catch(System.Exception e)
{
System.Console.WriteLine(e.ToString());
}
return 0;
}
}
}












No comments yet... Be the first to leave a reply!