I'm trying to upgrade an app to ServiceStack 4 but I'm getting an error with the reference to System.Web.WebPages.Razor
in Web.config
:
Could not load file or assembly 'System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
The offending reference is the exact same that is included in various ServiceStack examples:
<compilation targetFramework="4.5" debug="true">
<assemblies>
<add assembly="System.Web.WebPages.Razor,
Version=1.0.0.0,
Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
...
I tried to run the official examples (Razor RockStar and EmailContacts) but I'm also getting the same error when I run them.
If I change the library declaration to use Version=2.0.0.0
instead, I'm not getting any error.
So my question is:
Are the example wrong and should they be moved to 2.0.0.0 as well or am I doing something wrong?
My setup:
- Windows 8.1 Pro x64
- Visual Studio 2013 Pro
- App targeting for .Net 4.5, x86
- ServiceStack 4.0.15
The razor Web.config sections added by ServiceStack.Razor normally use the version of ASP.NET WebPages that's installed on your computer included with VS.NET installation and updates and is normally located under:
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\
This holds the different version of ASP.NET Web pages installed, e.g:
v1.0\
v2.0\
Another option for installing ASP.NET WebPages is via NuGet, i.e:
PM> Install-Package Microsoft.AspNet.WebPages
This will install the latest version of WebPages which is currently at v3.1.1 and means you would need to change the version number in the Web.config to Version=3.0.0.0.
You can install the specific 1.0.0.0 version of ASP.NET Web pages with:
PM> Install-Package Microsoft.AspNet.WebPages -Version 1.0.20105.408
Only configuration section used
ServiceStack doesn't use the WebPages implementation itself, the configuration is primarily included to keep VS.NET intelli-sense happy as well as providing a way to configure the default namespaces added to Razor pages.
Although this can also be done in code by adding to the Config.RazorNamespaces
collection, but adding them to the config section lets VS.NET knows about them so you can get proper intell-sense, otherwise it doesn't have any effect on the execution of the pages at runtime.