Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC4 minimum references

Since a new MVC 4 Internet project has no less that 47 references and 29 nuget packages. I'm wondering what the least number of references I can get away with. I'd like to choose my Javascript and ORM solutions. I basically just want the barebones MVC Framework. What can I get rid of ? And for bonus points what is the minimum I have to add to get WebApi working ?

like image 416
Mark Broadhurst Avatar asked Sep 24 '12 21:09

Mark Broadhurst


People also ask

What is mvc4?

ASP.NET MVC 4 is a framework for building scalable, standards-based web applications using well-established design patterns and the power of the ASP.NET and the . NET framework. This new, fourth version of the framework focuses on making mobile web application development easier.

How can we make field required in MVC?

Add the "[Required]" attribute to the field that you want to make mandatory for insertion. The Required attribute requires the "System. ComponentModel. DataAnnotations" namespace.


2 Answers

Just for the sake of completeness, here are the minimum references I found to be needed for a working ASP MVC application deployed to IIS (in my case version 7.5). That is to say, if you have these references only, your MVC application will run, and if you don't have all of them, it won't run. Also, keep in mind I'm speaking from a deployment perspective, not a local development web server perspective. Running locally without all these references may work but end up failing when deployed to IIS.

Minimum References

REFERENCE                        COPY LOCAL*
---------                        -----------
Microsoft.Web.Infrastructure     true
System                           false
System.Web                       false
System.Web.Http                  false
System.Web.Mvc                   true
System.Web.WebPages              true
System.Web.WebPages.Deployment   true
System.Web.WebPages.Razor        true

*Copy Local is set to false for these references when they're added to your solution. Set the Copy Local property for the references above accordingly to make sure the DLLs are put into the bin directory when building the project. That way, they will be picked up for deployment.

like image 188
Aron Boyette Avatar answered Sep 28 '22 05:09

Aron Boyette


So its been a while, On update 2 there seems to be a empty template which still has a load of unused references, Once you have created the solution you can safely remove the following references:

  • Microsoft.CSharp
  • Microsoft.Web.Infrastructure
  • Microsoft.Web.Mvc.FixedDisplayModes
  • Newtonsoft.Json
  • System.ComponentModel.DataAnnotations
  • System.Data
  • System.Data.DataSetExtensions
  • System.Drawing
  • System.EnterpriseServices
  • System.Net.Http.Formatting
  • System.Net.Http.WebRequest
  • System.Web.ApplicationServices
  • System.Web.DynamicData
  • System.Web.Entity
  • System.Web.Extensions
  • System.Web.Helpers
  • System.Web.Razor
  • System.Web.Services
  • System.Web.WebPages.Deployment
  • System.Xml
  • System.Xml.Linq

and from a Nuget point of view you can remove all of the packages except (and their dependencies) :

  • Microsoft.AspNet.WebApi
  • Microsoft.AspNet.Mvc
like image 21
Mark Broadhurst Avatar answered Sep 28 '22 03:09

Mark Broadhurst