¿Son realmente necesarios todos los ensamblajes de ASP.NET MVC 4 RC para una implementación de ASP.NET WebAPI RC?

When I created a "Empty WebAPI" project in Visual Studio 2010, several of the new assemblies to support the MVC web pages were added as references (an example of the few in the list below):

  • System.Web.Razor.dll
  • System.Web.WebPages.Deployment.dll
  • System.Web.WebPages.dll
  • System.Web.WebPages.Razor.dll

For the sake of cleanliness, I removed those DLL references that I wasn't using (or so I thought I wasn't "using"). When deploying to the server I would get exceptions like the following:

Exception message: Could not load file or assembly 'System.Web.Razor,Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

I am currently doing a bin deploy to the server with all of the assemblies it took until the JIT compliation errors ceased.

I understand the FileNotFoundException. I understand that the runtime is trying to resolve that reference.

Mis preguntas): Why is it necessary to carry around the MVC Razor assemblies when all you are trying to create is a WebAPI site? Is there another dependency that needs to be removed?

preguntado el 04 de julio de 12 a las 00:07

1 Respuestas

No, you don't need all those assemblies.

I always prefer to build my Web API projects from rayar. I don't use the templates. I simply create an empty ASP.NET Project and add the Microsoft.AspNet.WebApi Paquete NuGet.

Here are the references that seem to only be needed:

Microsoft.CSharp
Microsoft.Web.Infrastructure   // Microsoft.Web.Infrastructure NuGet package
Newtonsoft.Json                // Newtonsoft.Json NuGet package
System.Net.Http                // Microsoft.Net.Http NuGet package
System.Net.Http.Formatting     // Microsoft.AspNet.WebApi.Client NuGet package
System.Net.Http.WebRequest     // Microsoft.Net.Http NuGet package
System.Web.DynamicData
System.Web.Entity
System.Web.ApplicationServices
System.ComponentModel.DataAnnotations
System
System.Data
System.Core
System.Data.DataSetExtensions
System.Web.Extensions
System.Web.Http                // Microsoft.AspNet.WebApi.Core NuGet package
System.Web.Http.WebHost        // Microsoft.AspNet.WebApi.WebHost NuGet package
System.Xml.Linq
System.Drawing
System.Web
System.Xml
System.Configuration
System.Web.Services
System.EnterpriseServices

Respondido 04 Jul 12, 06:07

This is superbly helpful. Thanks! - Reacción21

How would you add the "help" section found in the web api template? The section where you browse to localhost/Help to see all apis .. - guiomie

System.Data.DataSetExtensions, System.Drawing and System.Web.DynamicData are not required in a typical WebAPI project and can be removed. - damieng

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.