Removed attribute AutoEventWireup from file Default.aspx.. Removed attribute CodeBehind from file Default.aspx.. Removed attribute AutoEventWireup from file DesktopDefault.aspx.. Removed
Trang 1The final step is a warning on how to handle the project if it is controlled by a source control system If
it is, you want to ensure that the project or any of its components are checked out by someone You also
want to ensure that the check-in capabilities are enabled This warning is shown in Figure A-7
Figure A-7
When you are ready to convert the project, click the Finish button The actual conversion process could
take some time, so allow a few minutes for it When the process is complete, you are offered a
comple-tion notificacomple-tion that also enables you to see the conversion log that was generated from the conversion
process (Figure A-8)
After the project is converted, you are presented with the conversion log, as shown in Figure A-9
Trang 2Figure A-8
Figure A-9
Trang 3As you look over the project in the Solution Explorer, notice that some major changes have been made to
the project Some of these changes include the following:
❑ All class files are removed from their folders and placed in the newApp_Codefolder The folder
from which the class files were removed is left in place, even if the folder is empty after all the
class files are removed
❑ All the Visual Studio NET 2002/2003 Web project files are deleted because Visual Studio 2008
does not use these any longer
❑ The application’s DLL is deleted from theBin folder
❑ All the.aspxpages have had their@Pagedirectives changed An example from the
Default.aspxpage shows that the previousc@Pagedirective was constructed as:
<%@ Page Language="c#" CodeBehind="Default.aspx.cs" AutoEventWireup="false"
Inherits="ASPNET.StarterKit.IssueTracker._Default" %>
❑ After the conversion process, the @Page directive now appears as:
<%@ Page Language="c#" Inherits="ASPNET.StarterKit.IssueTracker._Default"
CodeFile="Default.aspx.cs" %>
❑ The code-behind classes for the.aspxpages are converted to partial classes (presented here in
C#) This is what the code behind for theDefault.aspxpage looked like before the conversion:
public class _Default : System.Web.UI.Page
{
// Code removed for clarity }
❑ After the conversion process, the page class appears as shown here:
public partial class _Default : System.Web.UI.Page
{
// Code removed for clarity }
For a full list of changes, look for aConversionReport.webinfofile in the root of your solution The
partial text from this example conversion is presented in Listing A-4 This conversion report can get quite
large, but pay attention to everything that was done to your project In the following listing, some of the
four pages of this conversion report are shown
Listing A-4: The ConversionReport.webinfo file
This report shows the steps taken to convert your Web application from
ASP.NET 1.1 to ASP.NET 2.0
There may be some unresolved conversion issues you will need to manually fix
For more information, please refer to http://go.microsoft.com/fwlink/?LinkId=46995
or search for the help topic "Converting from Visual Studio NET 2002 or 2003"
Trang 4Conversion Started on project file IssueTrackerCSVS.csproj at April 17 2008,
16:48:39
=========================ERRORS===================
=========================WARNINGS=================
Warning: This web project was converted as a file-based web application If your
site contained any IIS meta-information, e.g sub-folders marked as virtual
directories, it is recommended that you close this web site and re-open it
using the Open Web Site command and selecting the Local IIS tab
=========================COMMENTS=================
Web.Config: Added ’xhtmlConformance’ attribute
Web.Config: added a reference for assembly System.DirectoryServices
Removed attribute AutoEventWireup from file Default.aspx
Removed attribute CodeBehind from file Default.aspx
Removed attribute AutoEventWireup from file DesktopDefault.aspx
Removed attribute CodeBehind from file DesktopDefault.aspx
Warning: Access level of ’Page_Load’ changed to ’protected’ in file
DesktopDefault.aspx.cs (Line 55)
Warning: Access level of ’Login’ changed to ’protected’ in file
DesktopDefault.aspx.cs (Line 62)
Warning: Access level of ’btnRegister_Click’ changed to ’protected’ in file
DesktopDefault.aspx.cs (Line 74)
Removed attribute Codebehind from file Global.asax
Removed attribute AutoEventWireup from file LogOff.aspx
Removed attribute CodeBehind from file LogOff.aspx
Warning: Access level of ’Page_Load’ changed to ’protected’ in file
LogOff.aspx.cs (Line 49)
Removed attribute AutoEventWireup from file NoProjects.aspx
Removed attribute CodeBehind from file NoProjects.aspx
Removed attribute AutoEventWireup from file Register.aspx
Removed attribute CodeBehind from file Register.aspx
Warning: Access level of ’SaveUser’ changed to ’protected’ in file
Register.aspx.cs (Line 55)
Removed attribute AutoEventWireup from file administration\projects\addproject.aspx
Removed attribute CodeBehind from file administration\projects\addproject.aspx
Warning: Access level of ’Page_Load’ changed to ’protected’ in file
Removed file Bin\ASPNET.StarterKit.IssueTracker.dll
Removed file IssueTrackerCSVS.csproj
Removed file IssueTrackerCSVS.csproj.webinfo
Project IssueTrackerCSVS.csproj has been converted successfully at April 17 2008,
16:50:12
After the project is converted, you can build and run the application from Visual Studio 2008 The appli-cation is now built and run on the ASP.NET 2.0 runtime
Remember: Do not upgrade production solutions without testing your programs first in a staging envi-ronment to ensure that your application is not affected by the changes between versions 1.0/1.1 and 2.0
or 3.5 of the NET Framework
Trang 5Migrating from ASP.NET 2.0 to 3.5
Visual Studio 2008 is the first version of the IDE that enables you to build applications at more than
one framework For instance, Visual Studio NET 2002 would only let you build 1.0 applications If you
wanted to build NET Framework 1.1 applications, then you were required to install and use Visual
Studio NET 2003 At the same time, Visual Studio NET 2003 would not enable you to build NET
Framework 1.0 applications, meaning that if you were dealing with applications that made use of either
framework, then you were required to have both IDEs on your computer
When you create a new project in Visual Studio 2008, you have the option of targeting the project at any
of the following frameworks:
Although you can open your NET 2.0 applications and work with them directly in Visual Studio 2008,
when you first open an ASP.NET 2.0 application in the IDE, you will be prompted to update the
applica-tion to ASP.NET 3.5 The dialog box that you are presented with is shown in Figure A-10
Figure A-10
Selecting Yes from this dialog box upgrades your ASP.NET 2.0 application to ASP.NET 3.5 You can also
right-click on the project in the Solution Explorer and select Property Pages from the provided menu
This gives you a dialog box that enables you to change the target framework of the application In this
case, you can see the default options on a Microsoft Vista computer (as shown in Figure A-11)
Although you can change the target framework as is illustrated in Figure A-11, you will find that it is
better to use Visual Studio 2008, as is shown in Figure A-10, to upgrade your ASP.NET applications
Although ASP.NET 2.0 and ASP.NET 3.5 use the same NET Framework 2.0 runtime, there are some
extra bolted-on additions available to ASP.NET 3.5 applications The hooks into these extra capabilities
are established through changes made by Visual Studio 2008 to the web.config file in the upgrade process
Some of the changes are detailed in the next few listings
Trang 6Figure A-11
The first major change to the web.config file is presented here
in Listing A-5
Listing A-5: Adding the NET 3.5 language compilers
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs"
type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" compilerOptions="/w:1">
<providerOption name="CompilerVersion" value="v3.5"/>
</compiler>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
compilerOptions="/optioninfer+">
<providerOption name="CompilerVersion" value="v3.5"/>
</compiler>
</compilers>
</system.codedom>
From this bit of theweb.config, you can see that there are two new compilers provided in this configu-ration code Both the C# 3.5 and Visual Basic 3.5 compilers are targeted with ASP.NET 3.5
Trang 7The next important change is in the<compilation>section of theweb.config, as shown here
in Listing A-6
Listing A-6: Adding new DLLs to ASP.NET with the 3.5 release
<compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
In ASP.NET 3.5, theSystem.CoreandSystem.Web.ExtensionsDLLs are added and made available to
this new version of the framework
In addition to these two major additions to theweb.config, you will find large sections of other changes
that mainly deal with the new AJAX capabilities that ASP.NET 3.5 provides If you are not using ASP.NET
AJAX in your applications, you can then delete these sections from the configuration file
Trang 8ASP.NET Ultimate Tools
I’ve always believed that I’m only as good as my tools I’ve spent years combing the Internet for
excellent tools to help me be a more effective developer There are thousands of tools out there to
be sure, many overlapping in functionality with others Some tools do one thing incredibly well
and others aim to be a Swiss Army Knife with dozens of small conveniences packed into their tiny
toolbars Here is a short, exclusive list of some of the ASP.NET tools that I keep turning back to
These are tools that I find myself using consistently while developing ASP.NET-based Web sites
I recommend that you give them a try if they sound useful Many are free; some are not In my
opinion, each is worth at least a trial on your part, and many are worth your hard earned money as
they’ll save you precious time
These tools can be easily searched for in your favorite search engine and found in the first page For
those that are harder to find, I’ve included URLs I also encourage you to check out my annually
updated Ultimate Tools List atwww.hanselman.com/toolsand you might also enjoy my weekly
podcast atwww.hanselminutes.comas we often discover and share new tools for the developer
enthusiast
Enjoy!
–Scott Hanselman
Debugging Made Easier
‘‘There has never been an unexpectedly short debugging period in the history of computers.’’
— Steven Levy
Trang 9There are so many great things about this application one could write a book about it Firebug is actually
a Firefox plug-in, so you’ll need to download and install Firefox to use it
The screenshot below shows Firebug analyzing all the network traffic required to download my page
This shows a very detailed graph of when each asset is downloaded and how long it took from first byte
to last byte as seen in Figure B-1
Figure B-1
It has a wealth of interesting features that allow you to inspect HTML and deeply analyze your CSS
including visualization of some more complicated CSS techniques such as offsets, margins, borders, and
padding Firebug also includes a powerful JavaScript debugger that will enable you to debug JavaScript
within Firefox Even more interesting is its JavaScript profiler and a very detailed error handler that helps
you chase down even the most obscure bugs
Finally, Firebug includes an interactive console feature like the Visual Studio Immediate window that lets
you execute JavaScript on-the-fly, as well as console debugging that enables classic ‘‘got here’’ debugging
Firebug is indispensable for the Web developer and it’s highly recommended
There is also Firebug Lite in the form of a JavaScript file You can add it to the pages
Trang 10YSlow is an add-on to an add-on Brought to you by Yahoo!, YSlow extends Firebug and analyzes your Web pages using Yahoo’s 13 rules for fast Web sites In Figure B-2, you can see Yahoo’s YSlow analyzing
my blog
Figure B-2
In some instances, I do well, but in others I receive a failing grade For example, rule number one says
to make fewer HTTP requests My site has too many external assets Each one of these requires an HTTP request, so I suspect I could speed up my site considerably with some refactoring
Not every rule will apply to you exactly, but Yahoo! knows what they’re doing and it’s worth your time
to use this tool and consider your grades in each category At the very least, you’ll gain insight into
how your application behaves For example, Figure B-3 shows how many HTTP requests and bytes are transmitted with an empty cache versus a primed one