Quote:
This post is based on my own research, after spending many hours last night trying to get the code in chapter 12 to work.
|
If your PC received a Windows update lately (6/1/2012), you may not be able to run the Web Helpers that come with ASP.NET Web Helpers Library 1.15.
As of last week, the WebMatrix Team officially released WebMatrix, version 2. With it, core ASP.NET Web Pages assemblies and some Web Helper Libraries where also upgraded.
Therefore, some of the code you are trying to compile won't work. Not even Nuget via the ASP Web Pages Administration site.
Here's a Diff report showing the files in the Final Code download folder/Chapter 13 that were affected by this change. This File Diff report shows the differences between what worked for WebMatrix 1 and what now works in version 2. As you can see, there are some entries in the web.config file that weren't there before.
Compare C:\Documents and Settings\Darel Johnson\My Documents\Downloads\Final Code 050484\Final Code\Chapter13\Classifieds\bin with C:\Documents and Settings\Darel Johnson\My Documents\Downloads\Final Code 050484\Final Code\Chapter13\Classifieds_2.0\bin
6/12/2012 5:42:40 PM
Filename Folder Comparison result Left Date Right Date Extension
..
Microsoft.Web.Helpers.dll . Binary files are identical 7/15/2011 12:33:32 PM 7/15/2011 12:33:32 PM dll
Microsoft.Web.Infrastructure.dll . Binary files are identical 6/12/2012 1:01:22 PM 6/12/2012 1:01:22 PM dll
NuGet.Core.dll . Binary files are different 6/12/2012 1:01:22 PM * 6/12/2012 1:08:14 PM dll
System.Web.Helpers.dll . Binary files are different 6/12/2012 1:01:22 PM * 6/12/2012 1:08:14 PM dll
System.Web.Razor.dll . Binary files are different 6/12/2012 1:01:22 PM * 6/12/2012 1:08:14 PM dll
System.Web.WebPages.Administration.dll . Binary files are different 6/12/2012 1:01:22 PM * 6/12/2012 1:08:14 PM dll
System.Web.WebPages.Deployment.dll . Binary files are different 6/12/2012 1:01:22 PM * 6/12/2012 1:08:14 PM dll
System.Web.WebPages.dll . Binary files are different 6/12/2012 1:01:22 PM * 6/12/2012 1:08:14 PM dll
System.Web.WebPages.Razor.dll . Binary files are different 6/12/2012 1:01:22 PM * 6/12/2012 1:08:14 PM dll
WebMatrix.Data.dll . Binary files are different 6/12/2012 1:01:24 PM * 6/12/2012 1:08:17 PM dll
WebMatrix.WebData.dll . Binary files are different 6/12/2012 1:01:24 PM * 6/12/2012 1:08:17 PM dll
Compare C:\Documents and Settings\Darel Johnson\My Documents\Downloads\Final Code 050484\Final Code\Chapter13\Classifieds with C:\Documents and Settings\Darel Johnson\My Documents\Downloads\Final Code 050484\Final Code\Chapter13\Classifieds_2.0
6/12/2012 5:42:23 PM
Filename Folder Comparison result Left Date Right Date Extension
..
Account . 6/2/2012 4:53:05 PM * 6/12/2012 1:07:41 PM
Admin . 6/2/2012 4:53:05 PM * 6/12/2012 1:07:42 PM
App_Code . 6/2/2012 4:53:05 PM * 6/12/2012 1:07:42 PM
App_Data . 6/2/2012 4:53:05 PM * 6/12/2012 1:07:42 PM
bin . 6/12/2012 1:01:24 PM * 6/12/2012 1:08:17 PM
Content . 6/2/2012 4:53:06 PM * 6/12/2012 1:07:42 PM
Scripts . 6/2/2012 4:53:06 PM * 6/12/2012 1:07:42 PM
Shared . 6/2/2012 4:53:06 PM * 6/12/2012 1:07:42 PM
_AppStart.cshtml . Identical 7/5/2011 8:24:04 AM 7/5/2011 8:24:04 AM cshtml
_PageStart.cshtml . Identical 6/19/2011 8:51:32 PM 6/19/2011 8:51:32 PM cshtml
Default.cshtml . Identical 7/15/2011 12:36:38 PM 7/15/2011 12:36:38 PM cshtml
Details.cshtml . Identical 6/19/2011 9:13:58 PM 6/19/2011 9:13:58 PM cshtml
robots.txt . Identical 6/12/2012 1:01:25 PM 6/12/2012 1:01:25 PM txt
Sell.cshtml . Identical 7/15/2011 12:37:52 PM 7/15/2011 12:37:52 PM cshtml
Web.config . Files are different 6/12/2012 1:01:24 PM * 6/12/2012 1:08:17 PM config
Web.config
HTML Code:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="false" targetFramework="4.0" />
</system.web>
<system.net>
<mailSettings>
<smtp deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="C:\Mail\" />
</smtp>
</mailSettings>
</system.net>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebMatrix.WebData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebMatrix.Data" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
So, how did I fix my problem. Well it took several steps, and I'm going to outline them.
Make a copy of the old website project you had been working on and rename it to something else - like Classifieds 2.0 site. You are going to upgrade that project to work with Web Pages 2.0.
Delete the following folders from App_Data in Classifieds 2.0 site:
\Admin
\packages
Delete the \bin folder from the your new sites root folder. Right clicking on these folders and selecting the
delete command should do the trick.
Getting WebMatrix 2:
Download WebMatrix 2 from the ASP.NET web site
http://www.microsoft.com/web/webmatrix/
This will install the newest WebPlatform Installer 4.0 (WebPI) and WebMatrix 2. As of today, the newest download file is:
webmatrix.3f.3f.3fnew.exe.
Install the software and install any dependencies the installer reports in the installation summary. The installation may take a while to finish, so making a cup of Tea would make a nice break.
Now the next step is crucial. The site project you want to upgrade must have the older ASP.NET Web Helpers Library 1.15 installed. Meaning you must go back to the old Classifieds site and copy the files from the following folders to the new site.
Copy:
\Admin
\packages\
to the \App_Data folder in you new Classifieds 2.0 site. Also copy the \bin folder as well.
Once you've copied the folders and completed the WebMatrix 2 installation, go ahead and launch the application.
On the
WebMatrix 2s main splash screen, click on
Open Site. You should see a menu pop up from there. Now you're going to import your site that you copied earlier into WebMatrix 2. Choose
Folder as Site and browse your PCs harddrive folders and find the site folder you want to import. Click
Open to start the import. At this point you should be in the Site Workspace.
Click on the
File Workspace. You should see your new Classifieds site created with a copy of your website files and the \bin folder and the \Admin and packages folder in App_Data. Select the sites root folder at the top -- Classifieds 2.0. Next try to
run the site. At some point, you should see a dialog box pop up asking you if you want to open the Site as Web Pages 1.0 site, or if you want to upgrade your site to Web Pages 2.0.
Choose to
upgrade your site to Web Pages 2.0. If that doesn't work, go back to the Site Workspace and change the
ASP.NET Web Pages Version to v2.0.20505.0.
My problem is now solved.