It does not run, because you put a class, into a server side script and
expect the Main function to run. Do not confuse a console application
(which is a standalone application), with an asp.net page (which is just a
page executed by the aspnet process - which is an application).
That being said, what you can put in a server side script block like that
are functions. These function can be event handler for events - in which
case they will run when the event occurrs. Or they can be regular functions,
which will be run when you call them (from an event, or an inline script
block).
You can also use <% %> server side script blocks, which can contain lines
of code. So something like:
<%
Response.Write("Hello");
%>
I recommend you get familiar with the asp.net model to learn about how the
code behind model works, and how the model for putting all your code
directly into the .aspx works.
"Cyril Kearney" <cy***********@hotmail.com> wrote in message
news:37**************************@posting.google.c om...
I am trying to learn C# over the internet. My ISP only allows .aspx
files. All .cs files are rejected.
The tutorials on the Internet are aimed at people able to run .cs
files from the command line. I can't do this.
Here's an almost universal first example.
using System;
class HelloWorld
{
public static void Main()
{
Console.WriteLine("Hello World !");
}
}
I've modified it to this and saved it as test.aspx but it doesn't run
<%@ Page language="c#" Debug="true"%>
<script Language="c#" runat="server">
using System;
class HelloWorld
{
public static void Main()
{
Response.Write("Hello World !");
}
}
</script>
I can't figure out what I'm doing wrong. Shouldn't all C# programs be
able to run in an .aspx file using Response.Write instead of
Console.WriteLine?
Thanks in advance for any help.