I have a few question regarding Microsoft.AspNet.WebApi NuGet package source code:
Where is located repository with Microsoft.AspNet.WebApi Nuget package source code.
What commit id corresponds to version 5.2.3 of the NuGet package.
What *.nuspec file was used to create Microsoft.AspNet.WebApi package?
Thanks!
I was looking for the exact same thing and I finally found it. This page lists out the versions and where they correspond in the source. It is v.3.2.3 that maps to 5.2.3.
Repository Tags and Version Numbers
BY Scott Hanselman: http://www.hanselman.com/blog/CreatingANuGetPackageIn7EasyStepsPlusUsingNuGetToIntegrateASPNETMVC3IntoExistingWebFormsApplications.aspx
POSTED TO AVOID LINK ONLY ANSWER!
HOW I MADE MY OWN NUGET PACKAGE AND YOU SHOULD TOO BY Scott Hanselman:
Step 0 - Go get the NuGet.exe command line here. Put it in the Path or somewhere.
Step 1 - Make a folder for your new package, go there via the commmand line and run "nuget spec"
C:\Users\Scott\Desktop\AddMvc3ToWebForms>nuget spec
Created 'Package.nuspec' successfully.
C:\Users\Scott\Desktop\AddMvc3ToWebForms>dir Package.nuspec
Directory of C:\Users\Scott\Desktop\AddMvc3ToWebForms
02/15/2011 02:23 AM 813 Package.nuspec
1 File(s) 813 bytes
Now, I changed this file's name and edited it thusly.
<?xml version="1.0"?>
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>AddMvc3ToWebForms</id>
<version>0.4</version>
<authors>Scott Hanselman</authors>
<owners>Scott Hanselman</owners>
<iconUrl>http://www.hanselman.com/images/nugeticon.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A totally unsupported way to quickly add ASP.NET MVC 3 support to your WebForms Application. Works on my machine.</description>
<tags>MVC MVC3 ASP.NET WebForms</tags>
</metadata>
</package>
Step 2 - Add stuff to your Content Folder
Since I want my NuGet package to add stuff to folders in my target Web Application, I put whatever I want in a folder called Content. Anything in that will show up in the root of my target project. This can be CSS, JS, CS or VB files, whatever. These files will all get dropped onto the project your package is applied to.
In my project I took the folders from an MVC application and put them in my NuGet folder structure. So, Content, Controllers, Models, Scripts, Views. Copied them right over from an existing blank ASP.NET MVC project.
My NuGet directory where I'm building the package
Step 3 - Decide what needs to be Pre-Processed
However, when my HomeController shows up in your project, Dear Reader, I don't want it to be in the namespace ScottMvcApplication! You want it in MvcApplication54 or whatever your project name is. I need pre-process the source a little to use your project's context, names, namespaces, etc.
For the files I want pre-processed automatically by NuGet, I add a .pp extension. In my example, HomeController.cs.pp.
Preprocessor files with a .pp extension
Then I add a few tokens I want replaced at install-time for that package. For example $rootnamespace$ or $assemblyname$. You can use any Visual Studio Project Property per the NuGet docs.
namespace $rootnamespace$.Controllers
{
public class HomeController : Controller
{
//snip
}
}
Step 4 - Decide what XML elements need to be merged (usually into web.config)
The next preprocessing that is common is adding elements to web.config. This is a nice little feature of NuGet because you just need to make a web.config.transform with the new elements and it will automatically and non-destructively add (and remove) them as needed. Here's my web.config.transform, for reference. Note this is not a full web.config. This is the one I added to my package in the control folder.
<configuration>
<appSettings>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages"/>
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Step 5 - Add any PowerShell script you might need, especially for adding references
Almost done. Most package won't need much PowerShell, but some do. You can have an install.ps1 and an uninstall.ps1 and do lots of things. These go in a folder called Tools that's next to Content (not inside.)
Here's my install.ps1.
NOTE: Currently today there's no way to STOP the installation of a package while it's happening, so if you try to install mine on NuGet 1.0 I'll just warn you and ask you to uninstall. In the future there will likely be a pre-install or a dependency check. Hence the version check there.
param($installPath, $toolsPath, $package, $project)
if ($host.Version.Major -eq 1 -and $host.Version.Minor -lt 1)
{
"NOTICE: This package only works with NuGet 1.1 or above. Please update your NuGet install at http://nuget.codeplex.com. Sorry, but you're now in a weird state. Please 'uninstall-package AddMvc3ToWebForms' now."
}
else
{
$project.Object.References.Add("Microsoft.CSharp");
$project.Object.References.Add("System.Web.Mvc");
$project.Object.References.Add("Microsoft.Web.Infrastructure");
$project.Object.References.Add("System.Web.WebPages");
$project.Object.References.Add("System.Web.Razor");
$project.Object.References.Add("System.ComponentModel.DataAnnotations");
}
Note that in (the future) NuGet 1.2 I won't need this code, I'll just add the references in my NuSpec file directly.
Step 6 - Pack it up
Go back to the command line and run nuget pack
C:\Users\Scott\Desktop\AddMvc3ToWebForms>nuget pack
Attempting to build package from 'AddMvc3ToWebForms.nuspec'.
Successfully created package 'C:\Users\Scott\Desktop\AddMvc3ToWebForms\AddMvc3ToWebForms.0.4.nupkg'.
Step 7 - Submit your package
Next, login to the NuGet Gallery (beta) and Contribute Your Package. Just walk through the wizard and upload the nupkg. You can also get an API Key and use the command line tool to do this automatically, perhaps as part of a build process.
Submitting my app to the NuGet Gallery
That's it. If you've got an open source librar
Related
I am using Visual Studio 2010 and I installed "Microsoft Report Viewer 2012 Runtime" hoping to test the new reporting system in SQL 2012. After which I cleared for ref to "Microsoft.ReportViewer.WebForms" from my Web.config and removed the ReportViewer control from my toolbox and added the new version 11 ReportViewer.
I added the new control to a testing page and for one it adds this register to the test page:
<%# Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
and it adds these entry to the Web.config:
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</buildProviders>
<httpHandlers>
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false" />
</httpHandlers>
<handlers>
<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
The control in the toolbox is the version 11 addition but the system keeps trying to ref the verion 10 edition. Also when I try to compile it I get the error:
The type 'Microsoft.Reporting.WebForms.ReportViewer' exists in both 'c:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\10.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll' and 'c:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\11.0.0.0__89845dcd8080cc91\Microsoft.ReportViewer.WebForms.DLL'
I think I had the exact same problem. If so, my solution was to delete all entries in web.config referencing ReportViewer, then do the same in References, build the project and then re-ADD a reportviewer in the page.
web.config will update with new handlers and assemblies for the newer version.
I had the same error, and resolved it by doing the following:
In the aspx page (HTML code), updated the #Register Version value to correspond to the version of the assembly I was using, and updated the PublicKeyToken value with the correct value for the assembly.
In your web config, it means you have specified both v 10 and 11 dlls. Remove one or the other.
I have removed the following entry from package.config and it works
<package id="MicrosoftReportViewerWebForms_v10" version="1.0.0" targetFramework="net45" />
I'm getting this error:
Error: AjaxControlToolkit requires ASP.NET Ajax 4.0 scripts. Ensure the correct version of the scripts are referenced. If you are using an ASP.NET ScriptManager, switch to the ToolkitScriptManager in AjaxControlToolkit.dll.
I've searched Hi and Low and can not resolve this. When I went to VS2008 I had the same issue and resolved it with changing my web.config
Now I ma running VS 2012 express. I've installed AjaxControlToolkit version 4.1.60501.0
Web.config:
<compilation debug="false" targetFramework="4.5">
<assemblies>
<add assembly="AjaxControlToolkit, Version=4.1.60501.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
and
<controls>
<add tagPrefix="cc1" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit"/>
</controls>
In ASPX I have:
<cc1:ToolkitScriptManager ID="ScriptManager1" runat="server">
</cc1:ToolkitScriptManager>
And I'm getting the above error. I know the Toolkit DLL is the correct version.
I am also running VS2008 / Ajax 3.5 on the same machine, but I cleared out the Temporary ASP.Net Files folder of all other projects and still have the issue. When I run this new VS2012 project, a ROOT folder is created in the in the Temp folder and the AjaxControlToolkit.DLL in that folder is version 4.1.60501.0
What needs to change?
Thanks Much,
Jim
Working against the current RC2 - the template that is generated Razor views includes:
#{
ViewBag.Title = "Details1";
Layout = "/Views/Shared/_Public.cshtml";
}
With a red squiggly under ViewBag.Title and this compiler error:'
Error 4 One or more types required to compile a dynamic expression cannot be found. Are you missing references to Microsoft.CSharp.dll and System.Core.dll? c:\Visual Studio 2010\Projects\myProj\Views\Webinar\Details1.cshtml 6 2 TTSTrain.Webinars.WebEntry
But the project builds and functions correctly. Is the error indicative of other problems that should be addressed?
I got the same problem after I removed the targetFramework attribute from the <compilation> element in the Web.config file.
Once I restored it to
<compilation debug="true" targetFramework="4.0">
Everything worked fine again!
I solved it in the following way:
First i noticed using gacutil (Global Assembly Cache Utility) that it contained two references to System.Core, one to version 4.0 and one to version 3.5. Apparently inside the razor views, even if in the project i had the correct reference to version 4.0, it was still using version 3.5 and that's why i was getting the error about the dynamic types.
To check if that's your case open as administrator Visual Studio Command Prompt and execute:
gacutil -l System.Core
To remove the reference to the old version of System.Core i did the following steps:
- cd %systemroot%\assembly\
From here you may have more that one "gac" directory, so you will have to search within each to find your component. For me, it was within the "gac_MSIL" directory.
- cd gac_msil
- cd System.Core
- cd <assembly version number>__<public key token>
- erase *.* Say "y" to are you sure.
- cd ..
- rd <assembly version number>__<public key token>
- cd ..
- rd System.Core
After that I opened my solution again in visual studio and the error was gone, it references properly to System.Core 4.0 and I was not getting the dynamic errors anymore :)
I hope it will help you as well,
Best, N.
Similar to #Kaiser's answer, I experienced this problem as a result of having multiple System.Core assemblies in the GAC.
I chose not to delete the 3.5 assembly, however. Instead, in the Views web.config, I modified the configuration/system.web/compilation node as follows:
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</assemblies>
</compilation>
The important line is the last assembly node: it tells the Razor compiler which GAC assembly version to use.
Once I did this, all was well in my Razor views.
I do not have this problem when running VS 2012 as administrator.
Otherwise, what worked for me:
in root web config have added as recommended reference to correct assembly as child of compilation node`
<system.web>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
</system.web>
set copy local = true properties for System.Core and Microsoft.CSharp`
Do you have a reference to Microsoft.CSharp and System.Core?
MVC Views (usually) get compiled dynamically when you access your site, not when you compile the application in VS. I imagine you will see issues when running the site. Just add the two references and you should be fine.
By using Peters answer i managed to solve the issue with Html.EditorFor(m => m.xxx) underline errors in the chtml files.
Althought the ViewBar error persisted.
So i changed the web.config like this
<compilation debug="true" targetFramework="4.5.1">
<assemblies>
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add assembly="Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</assemblies>
</compilation>
Notice the Microsoft.Csharp line.
The above did the trick and now the chtml editor is clear from the red underlines.
Thanks Peter
I had the exact same problem. By default, when you create an MVC3 app it sticks a web.debug.config and a web.release.config in the solution. When I got rid of those two items, the ViewBag issue resolved itself. It may have something to do with what Peter was saying above but I didn't test that.
That is the time when other fields in ViewBag is read. So if you are passing them from controller.
ViewBag.yourobjectDto = yourObjectDto;
make sure this line is not blocked through if condition or something.
Try
Page.Title = "Details1";
It might work.
If I set <compilation targetFramework="4.0"> in web.config, Visual Studio 2010 shows all Linq extension methods in ASPX files (not codebehinds). But when I change my project to target 3.5 (which supports Linq extension methods) Visual Studio removes the previously mentioned attribute in web.config, but Linq intellisense in APSX files goes with it as well.
Question
Is it possible to convince Visual Studio 2010 to not assume and fall back to 2.0 when editing ASPX files, so Linq extension methods would still be listed in intellisense dropdown?
Edit
Manually adding assemblies and import namespaces doesn't do the trick as I've pointed out in one of my previous questions, when I didn't know what was going on.
Problem reproduction
To reproduce this issue do the following:
In Visual Studio 2010 open Asp.net MVC project properties and target NetFx 3.5
Open web.config and remove targetFramework attribute if it's still there.
Write some code in the view itself (ASPX) that uses Linq extension method (ie. (new List<string>()).Any(s => string.IsNullOrEmpty())). You should see that Any is not recognised by Visual Studio 2010.
Start adding one configuration setting by one in web.config. There should be no difference about Any method.
Add <% # Imports ... %> to the view. There should be no difference about Any method either.
Running the application is not a problem. It runs and it also executes Any Linq extension method. No problem with that. Design time support is the issue here.
My web.config file
This is the complete content of my web.config file, that doesn't do the expected (I can include commented out parts as well, but that doesn't make any difference - original Asp.net MVC 2 project template doesn't include these either):
<?xml version="1.0"?>
<configuration>
<system.web>
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
<compilation debug="true" batch="true">
<assemblies>
<!--
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
-->
<add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<pages enableViewState="false">
<controls>
<add tagPrefix="SharePoint" assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.WebControls" />
</controls>
<namespaces>
<add namespace="Microsoft.SharePoint"/>
<add namespace="System.Collections.Generic"/>
<add namespace="System.Linq"/>
<add namespace="System.Web.Mvc"/>
<add namespace="System.Web.Mvc.Html"/>
<add namespace="System.Web.Routing"/>
<add namespace="MyApp.Objects"/>
<add namespace="MyApp.Web.General"/>
<add namespace="MyApp.Web.Helpers"/>
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="BlockDirectAccessHandler"/>
<add name="BlockDirectAccessHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
</configuration>
This is how it looks like in Visual Studio 2010. In the image you can't see the extra line <%# Import Namespace="System.Linq" %> that should be right after <%# Control ... %>, but I've tried with and without. system.web/pages/namespaces is the global setting for this anyway.
The root web.config for .NET 4.0 has System.Linq added to system.web/pages/namespaces. This is not the case for .NET 3.5 which, although it includes the Linq library, did not introduce changes to the root web.config for backwards-compatibility reasons, so you have to add it to the system.web/pages/namespaces in your web.config.
See ASP.NET Configuration File Hierarchy and Inheritance
I think it's because LINQ is assumed to be included in the 4.0 framework. For older versions, you can manually import the LINQ namespace by adding this to each ASPX page at the top:
<%# Import Namespace="System.Linq" %>
Or if you don't want to do that in each file, you can put it in your web.config.
Edit - As has been pointed out by others, your problem may come from the fact that you have System.Core commented out of your web.config, which is required for those extension methods.
Including System.Core assembly is of course important. But doesn't do anything is you don't also do this next thing.
To make everything work in Visual Studio 2010 as expected (and under framework 3.5) you have to add <system.codedom> configuration element in web.config as well. This is the part that was missing:
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>
I don't know if this was happening in the PR or Beta, but if I create an extension method on HtmlHelper, it is not recognized in a Razor powered page:
namespace SomeNamespace.Extensions {
public static class HtmlExtensions {
public static string Foo(this HtmlHelper html) {
return "Foo";
}
}
}
I added it to the <Namespaces> section in Web.config:
<pages>
<namespaces>
<add namespace="System.Web.Mvc" />
<!-- snip -->
<add namespace="SomeNamespace.Extensions"/>
</namespaces>
</pages>
But it throws a compile error when trying to view the page:
#Html.Foo()
If I recreate the page with WebForms it works fine. What's the deal?
Workaround
If I include #using SomeNamespace.Extensions in my Razor view, then it works, but I'd much rather just have it in Web.config
Since the Beta, Razor uses a different config section for globally defining namespace imports. In your Views\Web.config file you should add the following:
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<!-- Your namespace here -->
</namespaces>
</pages>
</system.web.webPages.razor>
Use the MVC 3 upgrade tool to automatically ensure you have the right config values.
Note that you might need to close and reopen the file for the changes to be picked up by the editor.
As the accepted answer suggests you can add "using" to all views by adding to section of config file.
But for a single view you could just use
#using SomeNamespace.Extensions
I had this same error in an MVC 4 application using Razor. In an attempt to clean up the web.config files, I removed the two webpages: configuration values:
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
Once I restored these configuration values, the pages would compile correctly and the errors regarding the .Partial() extension method disappeared.
I had this issue in VS 2015.
The following solved it for me:
Find "webpages:Version" in the appsettings and update it to version 3.0.0.0. My web.config had
<add key="webpages:Version" value="2.0.0.0" />
and I updated it to
<add key="webpages:Version" value="3.0.0.0" />
I found that putting this section in my web.config for each view folder solved it.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
This error tells you that you do not have the razor engine properly associated with your project.
Solution: In the Solution Explorer window right click on your web project and select "Manage Nuget Packages..." then install "Microsoft ASP.NET Razor". This will make sure that the properly package is installed and it will add the necessary entries into your web.config file.
In my case use VS 2013, and It's not support MVC 3 natively (even of you change ./Views/web.config): https://stackoverflow.com/a/28155567/1536197
Since ASP.NET MVC 3 RTM is out there is no need for config section for Razor. And these sections can be safely removed.