IIS and ASP.net

I’ve just installed XP professional on a new box and added IIS 5.0 so that I can create ASP.NET files and test to see if they work because we’re learning this language in one of my computer science classes.

However, I’m having some problems with IIS. When we start up XP does IIS “turn on” automatically? My problem is this: I’ve created my first test page:

saved it as “hello.aspx” in the wwwroot folder of e:\inetpub.
When I goto http://localhost/hello.aspx I get:

Hello and Welcome!<
(it should say this 7 times and in different font sizes, but it doesn’t)

This, I think, means IIS is running, but it’s not picking up the ASP.NET code, only the HTML.

I loaded the code onto a friend’s server at school that supports ASP.NET and it worked, so I know it’s not a problem with the code.
I’ve asked some friends and they’re stumped. Any help would be great! Thanks.

One of my hats at work is ASP programmer for our intranet site. However, I haven’t used the new ASP.net stuff, so I don’t know if there are new config things you have to do. Some things to check:

  1. Make sure that you have the virtual directory set up to allow execution of scripts.

  2. Start with a very basic page and get that working. Your page is very basic, but it does have a separated block of ASP and HTML. Try this first:

<%
Dim label
label=“Hello World!”
%>

Html>

<head>
<title>Hello and Welcome page</title>
</head>

<body>
<%=label%>
</body>

</html>

Get that going first. When installing a new environment or using a new language, get in the habit of quickly trying the absolute simplest program you can write, just to verify that the installation is correct.

One more thing: Learn to use good programming practices, including consistent indenting and use of white space. ASP pages can be a pain to follow the program logic, because of all the nested HTML and server code. I would have rewritten your program like this:

<%@Page Language=“VB” Debug=“True” %>

<html>

<head>
<title>Hello and Welcome page</title>
</head>

<body>
<center>

<%
Dim TextSize As Integer

For TextSize=1 to 7
%>
<font size= “<%=TextSize%>” >
Hello and Welcome!<br>
</font>

<% Next %>

</center>
</body>
</html>
As you write larger programs, good formatting is hugely important. Also important is good, consistent variable naming.

Sorry if I’m presuming too much about your experience. Maybe you know all this and just posted that snippet quickly. But you’d be surprised how many programmers I have interviewed who show me incredibly sloppy code.

There’s an excellent book called “Writing Solid Code” by Steve McGuire. Available from Microsoft Press. It’s almost required reading for all our software developers.

Okay, well the silly formatting thing removed all my indents. Probably did that to you too, which is why yours all lined up. But let me try again, just for yucks.

<%@Page Language=“VB” Debug=“True” %>

<html>

<head>
<title>Hello and Welcome page</title>
</head>

<body>
<center>



<% 
Dim TextSize As Integer 

For TextSize=1 to 7 
%> 
     <font size= "<%=TextSize%>" > 
          Hello and Welcome!<br> 
     </font> 

<% Next %> 

</center> 
</body> 

</html> 


Thanks Sam Your code seemed to work. I got the message Hello world! The orignal code however, with the for loop doesn’t work though. Prehaps my IIS isn’t supporting ASP.NET.

Regardless, I can still do asp pages, just not asp.net which is fine since I’m trying to learn the concepts of web front in and db back end on a webserver. I’ll continue to try and make some more regular asp pages and let you know if I have any more problems.

Also, what is a, virtual directory? Our prof never went over that, is that the wwwroot directory?
Thanks again!

You lost me there. Your code IS ASP. There’s nothing .NET in what you tried to do. There must have been something else going on.

If your browser displayed “Hello world”, then your ASP code is being executed.

If you’re not familiar with the concept of ‘virtual directories’, then you need to read your IIS documentation and maybe a good book on it before you get into serious ASP programming. You need to understand how web applications are built before you can use many of the features of ASP.

Don’t you need to put “Loop” after the next, or is that only when moving through a recordset?

You can always try asking on www.askasp.net too for help. Lurk around and find out the basics and if you still have questions, ask.