Questions tagged [asp.net-mvc]

The ASP.NET MVC Framework is an open source web application framework and tooling that implements a version of the model-view-controller (MVC) pattern tailored towards web applications and built upon an ASP.NET technology foundation.

Microsoft ASP.NET MVC Framework is an open-source web application framework and tooling that implements a version of the model-view-controller (MVC) pattern tailored towards web applications.

ASP.NET MVC Framework provides an alternative to the ASP.NET WebForms Framework for creating Web applications and is a more lightweight and testable framework than its WebForms cousin, even though they are both built upon the same base ASP.NET Foundation. It uses existing ASP.NET features, and in more recent versions has become more unified with WebForms via Microsoft's "One ASP.NET" initiative. The MVC framework is defined in the System.Web.Mvc assembly.

releases also tend to package additional technologies, such as the Razor View Engine, Web Optimization Framework, ASP.NET WebAPI, along with tooling such as Scaffolding and integration into Visual Studio.

The Model-View-Controller architectural pattern, upon which ASP.NET MVC is based separates an application into three main components: the model, the view, and the controller. The reason for this separation is to provide a cleaner overall architecture, while improving maintainability. This concept is often referred to as a "Separation of Concerns."

A model represents the state of a particular aspect of the application. Frequently, a model maps to a database table with the entries in the table representing the state of the application. A controller handles interactions and updates the model to reflect a change in state of the application, and then passes information to the view. A view accepts necessary information from the controller and renders a user interface to display that.

Since the ASP.NET MVC 4 release, Microsoft has shipped the framework both with a specific release of Visual Studio, as well as via the Nuget package management system. This package management method allows for easier "out of band" releases (versions not tied to a specific version of Visual Studio), along with a more module release so that sub-components can be chosen to be included or not (ASP.NET WebApi for example).

The latest announcements from Microsoft regarding ASP.NET MVC usually come from the .NET Web Development and Tools Blog, Visual Studio Blog or .NET Framework Blog. Other notable blogs relating to MVC are Scott Guthrie's Blog, ASP.NET by Scott Hanselman and Imran Baloch's Blog.

Unless you have a good reason not to, try to keep your MVC version current. There are bug fixes in newer versions, as well as new features. It makes little sense to create new projects using older versions of MVC today. The first thing you should do after creating a new project is open up the NuGet package manager and apply all updates (with the possible exception of jQuery 2.x. If you need compatibility with older browsers stay with the latest version jQuery 1.x, which is feature compatible with the 2.x line).

Versions shipped with Visual Studio

  • Visual Studio 2017 - ASP.NET MVC 5.2.3 - ASP.NET Core MVC 1.1.2
  • Visual Studio 2015 - ASP.NET MVC 5.2.0
  • Visual Studio 2013 - ASP.NET MVC 5.1.0
  • Visual Studio 2012 - ASP.NET MVC 5.0.0
  • Visual Studio 2010 - ASP.NET MVC 2 (no point releases)
  • Visual Studio 2008 - None (MVC was released after 2008 was)

Requirements by version

  • MVC 5.x - Visual Studio 2012 - CLR 4.0 - Framework 4.5
  • MVC 4 - Visual Studio 2010 - CLR 4.0 - Framework 4.0
  • MVC 3 - Visual Studio 2010 - CLR 4.0 - Framework 4.0
  • MVC 2 - Visual Studio 2008 - CLR 2.0
  • MVC 1 - Visual Studio 2008 - CLR 2.0

Current Releases (Available through NuGet) * Stable release 5.2.3 (February 9, 2015)

References

Frequently Asked Questions (FAQ)

Please note that most questions that may refer to a specific version of ASP.NET MVC will likely apply to newer versions as well. So if the question says MVC3, it likely also applies to MVC4 and MVC5.x, etc.

Tutorials (High quality external articles on Frequently asked topics)

200910 questions
1585
votes
48 answers

A potentially dangerous Request.Form value was detected from the client

Every time a user posts something containing < or > in a page in my web application, I get this exception thrown. I don't want to go into the discussion about the smartness of throwing an exception or crashing an entire web application because…
Radu094
  • 28,068
  • 16
  • 63
  • 80
1079
votes
13 answers

Html.Partial vs Html.RenderPartial & Html.Action vs Html.RenderAction

In ASP.NET MVC, what is the difference between: Html.Partial and Html.RenderPartial Html.Action and Html.RenderAction
Ghooti Farangi
  • 19,926
  • 15
  • 46
  • 61
874
votes
23 answers

File Upload ASP.NET MVC 3.0

(Preface: this question is about ASP.NET MVC 3.0 which was released in 2011, it is not about ASP.NET Core 3.0 which was released in 2019) I want to upload file in asp.net mvc. How can I upload the file using html input file control?
user637197
  • 8,897
  • 4
  • 16
  • 6
779
votes
35 answers

How do you handle multiple submit buttons in ASP.NET MVC Framework?

Is there some easy way to handle multiple submit buttons from the same form? For example: <% Html.BeginForm("MyAction", "MyController", FormMethod.Post); %> <%…
Spoike
  • 119,724
  • 44
  • 140
  • 158
737
votes
36 answers

How do you create a dropdownlist from an enum in ASP.NET MVC?

I'm trying to use the Html.DropDownList extension method but can't figure out how to use it with an enumeration. Let's say I have an enumeration like this: public enum ItemTypes { Movie = 1, Game = 2, Book = 3 } How do I go about…
Kevin Pang
  • 41,172
  • 38
  • 121
  • 173
728
votes
30 answers

Can I set an unlimited length for maxJsonLength in web.config?

I am using the autocomplete feature of jQuery. When I try to retrieve the list of more then 17000 records (each won't have more than 10 char length), it's exceeding the length and throws the error: Exception information: Exception type:…
Prasad
  • 58,881
  • 64
  • 151
  • 199
712
votes
16 answers

RedirectToAction with parameter

I have an action I call from an anchor thusly, Site/Controller/Action/ID where ID is an int. Later on I need to redirect to this same Action from a Controller. Is there a clever way to do this? Currently I'm stashing ID in tempdata, but when you…
Eric Brown - Cal
  • 14,135
  • 12
  • 58
  • 97
697
votes
7 answers

In MVC, how do I return a string result?

In my AJAX call, I want to return a string value back to the calling page. Should I use ActionResult or just return a string?
user67033
  • 15,945
  • 6
  • 21
  • 11
675
votes
9 answers

ASP.NET MVC - Set custom IIdentity or IPrincipal

I need to do something fairly simple: in my ASP.NET MVC application, I want to set a custom IIdentity / IPrincipal. Whichever is easier / more suitable. I want to extend the default so that I can call something like User.Identity.Id and…
Razzie
  • 30,834
  • 11
  • 63
  • 78
614
votes
16 answers

Passing data to a bootstrap modal

I've got a couple of hyperlinks that each have an ID attached. When I click on this link, I want to open a modal ( http://twitter.github.com/bootstrap/javascript.html#modals ), and pass this ID to the modal. I searched on google, but I couldn't find…
Leon Cullens
  • 12,276
  • 10
  • 51
  • 85
586
votes
8 answers

Compile Views in ASP.NET MVC

I want an msbuild task to compile the views so I can see if there are compile time errors at well... compile time. Any ideas?
John Oxley
  • 14,698
  • 18
  • 53
  • 78
577
votes
36 answers

JQuery - $ is not defined

I have a simple jquery click event and a jquery reference defined in the site.master
Paul Creasey
  • 28,321
  • 10
  • 54
  • 90
571
votes
8 answers

How to get ELMAH to work with ASP.NET MVC [HandleError] attribute?

I am trying to use ELMAH to log errors in my ASP.NET MVC application, however when I use the [HandleError] attribute on my controllers ELMAH doesn't log any errors when they occur. As I am guessing its because ELMAH only logs unhandled errors and…
dswatik
  • 9,129
  • 10
  • 38
  • 53
568
votes
54 answers

Visual Studio debugging/loading very slow

I'm at wit's end. Visual Studio is typically painfully slow to debug or just plain load ("start without debugging") my ASP.NET MVC sites. Not always: at first, the projects will load nice and fast, but once they load slow, they'll always load slowly…
545
votes
19 answers

How to fix: Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list

I am configuring an MVC 3 project to work on a local install of IIS and came across the following 500 error: Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list. It turns out that this is because…
hspain
  • 17,528
  • 5
  • 19
  • 31
1
2 3
99 100