I have written my first "Hello World" program in ASP. I thought I would post here how it is done and ask if anyone can suggest how to incorporate C#.

The first step was to download the free "Microsoft Visual Web Developer 2005 Express Edition" from microsoft.com

The next step was to install and run this program. Then create a new web page by clicking on File -> New Web Page. This will bring up this windowL


From this window, pick "ASP.Net Web Site" and click the OK button.

Then I edited the Default.aspx file so it reads like this:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
    HelloWorldLabel.Text = "Hello, world!"

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
    <asp:Label runat="server" id="HelloWorldLabel"></asp:Label>


And this works.

So the next step is to incorporate C# into this "Hello World" program. Can anyone make a suggestion?

9 Years
Discussion Span
Last Post by blacklocist

Well, your file is currently set up to use a VB.NET code file (see the Language="VB" in the Page declaration?) and it looks for that code in Default.aspx.vb. If you add a new page to your website, and select C# as the code-behind language, you'll be ready.

I've attached a screenshot from Visual Studio 2008 (I don't have 2005 handy, but they're similar at this point). The red arrow shows where the language is. The checkbox by the green arrow selects if you want your code at the top of the page (like you did - this is ASP style), or in a separate file dedicated to code (this would be YourPage.aspx.cs, which is ASP.NET style).

As an aside, I recommend you try out Visual Web Developer 2008. There's a lot of new features that have been added in the new version. :)

Attachments newWebform.png 81.69 KB

OK, I fixed everything so that it will work -- or so I thought.

I decided to install some ASP.NET sample code. The installation gave me an error saying that I needed to install the latest version of IIS.

So went into the control panel to add IIS like this:


But now, something strange is happening. It is almost as if I have taken one step forward and two steps backwards. Even the most simple ASP.NET program (one I generate without modifying any code at all) produces this in the browser window when I build it and run it:


Is there some sort of special routine I need to do for IIS?


Taking a wild guess at this (since I'm not very familiar with IIS), I'd first assume that for some reason it's not set to process .aspx files through the ASP engine. My assumption is largely based on the fact that the ASP markup should never reach the client. Unfortunately, I don't know how to reconfigure that properly.

One potential workaround is to create your projects as File System websites. This will cause them to be processed by Cassini, which is a mini-IIS packaged with VWD, instead of using your computer's IIS. Note that this will cause complications if you try to deploy your websites to a server, as the server will use IIS. But if you're just playing around with ASP.NET, file system webs should get you going for now.


IIS was installed and started after the .NET framework.
This was the cause of some problems.
But I fixed it.

On the command line, I went to


and went to the directory of the latest version:


and I typed

aspnet_regiis -i

the computer responded that it was installing ASP.NET

and now, my programs work.


aspnet_regiis -i

So many times have I redone my dev machine and couldn't figure out why IIS wasn't working right. Then I forgot this little step and I feel 1 inch tall.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.