Hi Bob,
Steps to follow in order to pass to ASP.NET after that the installation of
the
.NET Framework and VS.NET has been completed:
1.Create a copy of the directory (\MYSITE) containing the existing ASP web
application
and rename it (\MYSITE_NET).
2.Make the new /MYSITE_NET directory a virtual directory through IIS or
PWS.
3.Open VS.NET and create a new empty Web project
(/MYSITE_NET/myPrjNet.vbproj).
4.Add to the new project the asp files from our web application. To do
this,
from the "Solution Explorer"
window, right-click on myPrjNet.vbp and choose "Add" -> "Add Existing
Item..." The file select window
will open in order for you to select the files - to view ASP files
select
the filter "Web Files."
Start the .NET Application
The first step in migrating the application is to set the default start
page
(the first file that is executed
when we run the application). You can do this by right-click on the
appropriate file in the "Solution Explorer"
window and selecting "Set As Start Page." For example:
/MYSITE_NET/default.asp. At this point, we can
already execute our application by starting it (without debugging) by
pressing CTRL+F5. As long as your
browser is in "online" mode and your local web server is started it should
work as always.
ASP.NET is perfectly compatible with ASP and the two co-exist quite well
together. If we experiment and try
renaming our ASP files to ASPX things change a little.
Rename MyForm.asp To MyForm.aspx
At this point we can try the experiment mentioned previously: we'll choose
an ASP file and tell Visual Studio to
exclude it from the project. You do this by right-clicking on the file in
the "Solution Explorer" window and selecting
"Exclide From Project." Once the file is excluded, we'll rename it and
then
re-add it as we did originally. You'll most
likely see a message something like this:
"There is no class file in the project associated with the Web Form
'MyForm.aspx'. Create a new class file now?"
You'll probably want to select the "Yes" button. The framework, at this
point, will do two things:
It will insert the following line at the top of MyForm.aspx:
<%@ Page CodeBehind="MyForm.aspx.vb" Language="vb"
Inherits="myPrjNet.MyForm">
This directive to the compiler that is included in most all ASP.NET files
provides a number of pieces of information so
the compiler can compile the page correctly. The main parameters are:
[CodeBehind]: Where to find the code, that is the class, that is "behind"
the ASPX page. In our sample case it would MyForm.aspx.vb.
[Language]: The language used: VB, C#, etc...
[Inherits]: The parent class from which our page inherits attributes and
methods. Almost always defined in the codebehind file.
[Debug]: Indicates whether the page should be executed in debug mode. Must
be either True or False. As we've already mentioned,
this option does not have to be set in the individual file. You can set it
in the web.config file for all pages in the project.
It will generate the file MyForm.aspx.vb:
Effectively what we want to do is to move nearly all of the code written
in
the original page (MyForm.asp) to the new
code-behind file (MyForm.aspx.vb). In particular, all the Functions and
Subs
defined in the original asp file will now
become methods of our class (after we've added the correct modifier -
Public, Protected. or Private). All classes
defined in this way derive from the parent class: System.Web.UI.Page and
possess two main Private methods:
Page_Init() and Page_Load(). More information on the parameters and use of
these methods can be found on
the web and in the .NET Framework documentation.
After you've moved all the event handlers and code to the MyForm.aspx.vb
file, the "operating" code, that is the
code remaining between the <body> tags should be all that remains in the
ASPX page. Most of the common errors
you'll run into when migrating are results of the changes from VB to
VB.NET:
All variables must be declared and eventually typed. The "Variant" type no
longer exists. Unspecified variables default to
the generic "Object."
All method calls require parentheses.The instructions Set and Let are no
longer necessary (everything is now an object!).
Obviously it is not necessary to convert all your ASP pages to ASP.NET As
we've already mentioned, the two can inhabit
the same atmosphere and can calmly co-exist. But, if we declare of
variable
of session scope in an ASP.NET page, it will
not be visible to and ASP pages. It is therefore necessary to convert all
the files which need to access these variables to
ASP.NET using the method described above.
As for read up for .NET, you can refer to the online MSDN which has
exhaustive
study material for .NET.The link is as follows.
http://msdn.microsoft.com/default.aspx
HTH
Mona
BobRoyAce said:
I would really appreciate recommendations for sources of materials on
migrating ASP applications to ASP.NET (books, URL's, etc.). Also, is there
a magazine that is particularly good for .NET stuff. I am just starting my
journey into the .NET world, moving from a pure ASP one.