Re: How to run a Hello world in .NET Framework

Mitch Denny <[email protected]> Wed, 26 Jun 2002 12:05:47 +1000
Newsgroups gmane.comp.windows.devel.dotnet.general
Organization MitchDenny
Message-ID <[email protected]>
Mathew,

The process of developing with the .NET Framework would be
alot easier if you downloaded the entire SDK, on the
download page at the ASP.NET site, download the second
option, the one you have is just the redistributable:

        http://www.asp.net/download.aspx

You can do some things with just the redist but you don't
get any documentation which is really valuable, its really
tuned for runtime, not development.

Anyway, in order to do a hello world sample:

        using System;

        public class HelloWolrd
        {

                public static void Main()
                {

                        Console.WriteLine("Hello World!");

                }

        }

You compile this with the following command:

        csc.exe /reference:System.dll HelloWorld.cs

It will produce an executable called:

        HelloWorld.exe

If you have trouble compiling, the path could be the
issue, you may need to add the following to your path:

        C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705

Building a similar HelloWorld example using ASP.NET is a
little bit more involved but quite simple once you get the
hang of it. When you use code behind there are two files
that you need to have, the *.aspx file and the *.aspx.cs
file, in this example:

        HelloWorld.aspx
        HelloWorld.aspx.cs

Note that what you name the code behind file is totally
up to you, but this is the convention that VS.NET uses. The
contents of the *.aspx file is as follows:


        <%@ Page Inherits="HelloWorld" Language="C#" %>

        <html>

                <head>

                        <title>HelloWorld</title>

                </head>

                <body>

                        <form runAt="server">

                                <asp:literal id="Message" runAt="server"
/>

                        </form>

                </body>

        </html>

And the *.aspx.cs file is:

        using System;
        using System.Web;
        using System.Web.UI;
        using System.Web.UI.WebControls;

        public class HelloWorld : System.Web.UI.Page
        {

                protected override void OnLoad(EventArgs e)
                {

                        this.Message.Text = "Hello World!";

                }

        }

Copy the HelloWorld.aspx file to the C:\Inetpub\wwwroot
directory on your computer (I am assuming that you have
IIS installed), then execute the following command on
the *.aspx.cs file:

        csc.exe
                /reference:System.dll
                /reference:System.Web.dll
                /target:library
                /out:HelloWorld.dll
                HelloWorld.aspx.cs

That will produce a file called HelloWorld.dll, you
need to copy that file to the bin directory under your
IIS application, in this case:

        C:\Inetpub\wwwroot\bin

You may need to create that directory if you haven't
gone through this process before. Once you have done
this then you can request the page at the following
URL:

        http://localhost/HelloWorld.aspx

Anyway, that should get you started.

----------------------------------------
- Mitch Denny
- [email protected]
- +61 (414) 610-141
-

-----Original Message-----
From: The DOTNET list will be retired 7/1/02
[mailto:[email protected]] On Behalf Of Mathew James
Sent: Tuesday, 25 June 2002 17:12
To: [email protected]
Subject: [DOTNET] How to run a Hello world in .NET Framework


Hi all,

  I have recently downloaded .NET Framework(21 MB) from Microsoft site
and installed in my PC (Win2k). Now How should I start to run a small
application say (Hello World) with a small content in a code behind page
also.

Please Help me !!

Thanks in Advance
Mathews.

You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.