This article is currently in the process of being translated into Chinese (~3% done).

The basics:

Hello, world!

在幾乎每個程式語言指導內,你將找到最經典"Hello, world!"範例,我何必去打破這個傳統呢?讓我展示給您如何從ASP.NET對世界說哈囉。在Solution Explorer使用雙擊,開啟Default.aspx(假如它尚未開啟)。它已經包含一堆HTML標記語言,和一些您可能不認得的東西,如在頂端的頁面指引,或是form標籤的runat屬性。這所有都將在之後解釋,現在,我們想要看一些執行程式碼。


<asp:Label runat="server" id="HelloWorldLabel"></asp:Label>

Secondly, add this script block somewhere on the page, preferably below the Page directive in the top:

    HelloWorldLabel.Text = "Hello, world!";

If you haven't worked with ASP.NET before, I'm sure there's a bunch of things that you're wondering about now, but as I said, this is all about seeing some results right now. To see the page in action, use Debug -> Start Without Debugging, or simply press F6. Visual Studio will now compile your project, and launch the page you're working on in your default browser. The page will simply have a piece of text which says "Hello, world!" - congratulations, you have just created your first ASP.NET website! Here is the complete listing:

    HelloWorldLabel.Text = "Hello, world!";
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" >
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
<asp:Label runat="server" id="HelloWorldLabel"></asp:Label>
This article has been fully translated into the following languages: Is your preferred language not on the list? Click here to help us translate this article into your language!