How to compile VB functions

  • Thread starter Thread starter NRGeti
  • Start date Start date
N

NRGeti

I am learning ASP.NET using the book, "ASP.NET for Dummies". In the chapter
introducing writing your own functions, I cannot get the example to run when
I call it with LOCALHOST. It produces the IE cannot find page error because
it doesn't know how to compile the function.

I can execute .ASPX examples just fine using LOCALHOST.

What else do I need to do set up on my PC to be able to compile these
functions?

Here is the example code:

<%@Page Explicit="True" Language="VB" Debug="True" %>
<html>
<script runat="server">

Function RollDie As Integer
Dim Roll As Integer
Randomize
Roll = Int(Rnd * 6) + 1
Return(Roll)
End Function

</script>

<body>
<p>I'll roll two dice; let's see what
we get!</p>
<%
Dim FirstRoll, SecondRoll As Integer
FirstRoll = RollDie
SecondRoll = RollDie
%>
First roll: <%=FirstRoll%><br>
Second roll: <%=SecondRoll%><br>
</body>
</html>
 
I call it with LOCALHOST. It produces the IE cannot find page error
because
it doesn't know how to compile the function.

If you're talking about a 404 Page Not Found error, that has nothing to do
with compiling anything. It means that the URL you requested in your browser
doesn't exist on the server.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.
 
That is probably true. If I put this example on my own server, then it
compiles and runs. The question now is how can I get it to execute from the
LOCALHOST URL? All the system stuff that ran from the server exists on my PC
so how would I direct LOCALHOST to use it?
 
Well, I'm not sure. Usually, localhost refers to your local web server.
Apparently, you're using it to denote something else?
What is the URL you are using to get it from your local machine, and what is
the file location of the ASPX file?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.
 
I haven't changed anything in localhost. It still is 127.0.0.1

http://localhost/hello/rolldie.aspx (This fails to compile the function and
outputs the Page Cannot Be Displayed error screen. Port 80)
http://www.myhostname.com/hello/rolldie.aspx (This works.)

I have to change the port number in the property sheet when testing the two
formats above.

Another issue is to set up the property sheet so that I can use two
different port numbers for the default web site. Is this possible? The
Advance button looks like I can add any ports, but when I add them, they do
not seem to do anything.
 
I haven't changed anything in localhost. It still is 127.0.0.1
http://localhost/hello/rolldie.aspx (This fails to compile the function and
outputs the Page Cannot Be Displayed error screen. Port 80)

Let's forget about whether it's compiling anything for now, and forget about
port 80, unless you've done some reconfiguring of your local IIS.

Are you sure that ASP.Net is installed on your local web server? If not, to
do so, you would run the following command-line utility (adjust paths
according to your local system):

C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -i
Another issue is to set up the property sheet so that I can use two
different port numbers for the default web site. Is this possible? The
Advance button looks like I can add any ports, but when I add them, they do
not seem to do anything.

I don't know what Property Sheet you're referring to, as we haven't
discussed what software you're developing with yet.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.
 
OK. That was the problem. I needed to install ASP.NET into my local web
server. Since I am new to all of this, I had no clue as to how to do it.
When I downloaded the ASP framework last week, I just followed the prompts
without understanding what was happening. Apparently the framework was
installed in such a way that the IIS web server was able to find it but not
the local one.

That leaves the final issue. How can I execute .ASPX files on either
localhost or myhostname without having to change the port number for the
corresponding web server. For example, I have to set it to 80 for localhost
and some other port for myhostname. What I want to do it set up a web host
on my own PC and use it for testing.

The property sheet where I change the ports is found by running the IIS
Microsoft Management Console then right-click on the Default Web Site in the
folder tree of the IIS screen. Then click on Properties and go to the Web
Site tab.

I have to enter the TCP port for the web server I want to run. The Advanced
button opens a screen, Multiple identities for this Web Site. I was under
the impression that I can add other IP Addresses and ports here. But they
don't do anything. I guess I don't understand the purpose of this feature.
 
Well, since you don't really understand how to administer IIS (yet), my
suggestion would be that you leave the Advanced features alone. IIS has
default settings that are default because they are the most commonly-used.
In any case, you certainly don't need to change the port number of any of
your local web sites. Let me try to explain a bit:

A web site is an entity on a web server. The web server is a listener that
listens for HTTP requests on a TCP/IP port. The default port is 80 for HTTP.
The location of a web site is determined by the IP address of the web site,
which, in the case of a stand-alone machine such as your home machine, is
generally the same IP address as the machine. On an Internet Domain web
server, the machine may host more than one IP address, but that's an
advanced topic. In a web site, you can have multiple child webs, which are
designated by a forward slash after the IP address or domain name of the web
site, plus the folder name of the sub-folder containing the child web site.
Therefore, you can create multiple web sites that live on the same IP
address under a root web. That is what you want to do with your machine's
ASP.Net projects.

The domain name is a convenience for us humans, who don't speak numbers very
well. It is translated by the computer to an IP address when it is used.
This is either done by the computer itself, or by a Domain Name Server. In
the case of your local web server, the local machine uses the name
"localhost" for the local (internal) IP address of the machine, which is
127.0.0.1. You can also access the local machine's root web via the machine
name.

So, as you can see, it doesn't matter that your local machine and the remote
web site both use TCP/IP port 80; almost all web sites do. The real
difference is the IP address of the web server. And again, you can create as
many sub-webs as you wish. To make each sub-web a separate ASP.Net
application, you can use the IIS Admin snap-in to create an Application for
any sub-folder of the root. Just right-click the sub-folder, select
"Properties" from the context menu, and in the Directory tab, click the
"Create" button next to the "Application Name" box. Once this is done, the
sub-directory is now a sub-web.

Good luck!

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.
 
Thank you for all of your help and patience. I know it is frustrating
dealing with inexperienced users but I am very interested in learning all of
this stuff. The big problem is knowing where to start. Reading a thousand
pages of help files from start to finish is not a good way to learn. So I
need to start with things that I have immediate problems with and go on from
there.

Can you suggest some simplified reading material to get me to this next
step?
 
Thank you for all of your help and patience. I know it is frustrating

I haven't needed any patience dealing with you, my friend. It has been my
pleasure to help you as others have helped me.
Can you suggest some simplified reading material to get me to this next
step?

Can you define what the next step is? Are you still having a problem?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.
 
I understood the information you put in your last note. I am going to resume
studying ASP.NET. The other step is to learn IIS which is a different topic
than what we started with here. I am going to switch to the
microsoft.public.inetserver.iss newsgroup to discuss how I can put two IP
addresses on the same default web page. I found a web site that discusses
this topic but I haven't been successful doing it.
http://www.iisanswers.com/Top10FAQ/t10-hostheaders.htm
 
I was able to get the two addresses working yesterday. It took me about 3
hours of fiddling with all of the settings. I found that I had to start my
TZO Dynamic DNS program as a service; there was a checkbox in one of its
menus to allow it.

The discussion in the link I gave you last time was correct in how to
actually set up the Advance menu for two or more addresses. But even here it
was tricky. I finally just deleted all of the default ones and entered the
new ones but with the Port 80 entry first in the list. I also had to
explicitly specify 127.0.0.1 and localhost rather than the generic text
provided by MS. It also took awhile to figure out exactly what text to use
for my remote host name. In my case I had to leave off the "www." part.
 
Back
Top