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
40
votes
3 answers

Windows Workflow Foundation 4 and ASP.NET MVC

We are evaluating Windows Workflow Foundation 4 to use in MVC 3 based Web Applications. We would like to create flexible order workflows for different projects. Does anybody know good information about the general architecture or hands-on-labs for…
slfan
  • 8,950
  • 115
  • 65
  • 78
40
votes
1 answer

Custom Authorize Attribute

I'm building my own membership system and I want nothing to do with the MS Membership provider. I've looked around the internet and here on StackOverflow but all I could found was membership providers built on top of the MS Membership…
Kassem
  • 8,116
  • 17
  • 75
  • 116
40
votes
7 answers

How do I delete an object from an Entity Framework model without first loading it?

I am quite sure I've seen the answer to this question somewhere, but as I couldn't find it with a couple of searches on SO or google, I ask it again anyway... In Entity Framework, the only way to delete a data object seems to be MyEntityModel ent =…
Tomas Aschan
  • 58,548
  • 56
  • 243
  • 402
40
votes
5 answers

How do I generate a URL outside of a controller in ASP.NET MVC?

How do I generate a URL pointing to a controller action from a helper method outside of the controller?
Shawn Mclean
  • 56,733
  • 95
  • 279
  • 406
40
votes
5 answers

MVC3 Valums Ajax File Upload

I'm trying to use valums ajax uploader. http://valums.com/ajax-upload/ I have the following on my page: var button = $('#fileUpload')[0]; var uploader = new qq.FileUploader({ element: button, allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],…
ShaneKm
  • 20,823
  • 43
  • 167
  • 296
40
votes
6 answers

What is the difference between Razor and ASPX?

Is there any difference between Razor and ASPX in a MVC project? Is it just about syntax? That's what I think after reading this... Am I wrong?
BrunoLM
  • 97,872
  • 84
  • 296
  • 452
40
votes
2 answers

Asp.Net Core - simplest possible forms authentication

I have this old MVC5 application that uses forms authentication in the simplest possible form. There is only one account stored in web.config, there are no roles etc.
Pelle
  • 2,755
  • 7
  • 42
  • 49
40
votes
4 answers

ASP.NET MVC Redirect with model

I currently have a method in my controller which accepts a form collection, saves the data, and then displays the data in a 'Details' page. At the moment, the code currently looks something like: [HttpPost] public ActionResult Create(PersonModel…
user460667
  • 1,870
  • 3
  • 19
  • 26
40
votes
1 answer

How do I add the css class attribute to a textbox in razor?

I have tried: @Html.TextBoxFor(m => m.UserName, new {@class='textbox'}) which isn't working.
Magnus Gladh
  • 1,817
  • 4
  • 20
  • 31
40
votes
5 answers

Enable client validation in Razor views (ASP MVC 3)

I try to add client side validation using this line of code: @Html.EnableClientValidation() But I keep getting this error message: Compiler Error Message: CS1502: The best overloaded method match for…
Martin at Mennt
  • 5,677
  • 13
  • 61
  • 89
40
votes
2 answers

Does it matter where AsNoTracking in Entity Framework is called

Does it matter where the AsNoTracking method is called when writing an Entity Framework query? e.g. var matchingCustomers = context.Customers.AsNoTracking().Where(n => n.city == "Milan").Skip(50).Take(100).OrderBy(n => n.Name).ToList(); var…
user1786107
  • 2,921
  • 5
  • 24
  • 35
40
votes
2 answers

What exactly does / do in web.config in MVC 5?

I am about to migrate a bunch of projects from .NET 4.0 + MVC 3 to .NET 4.5.2 + MVC5. To make this easier, I've created a new blank MVC project to compare DLL references and some other stuff such as web.config. In the latter, the following entries…
MarioDS
  • 12,895
  • 15
  • 65
  • 121
40
votes
10 answers

The required anti-forgery cookie "__RequestVerificationToken" is not present

My website is raising this exception around 20 times a day, usually the form works fine but there are instances where this issue occur and I don't know why is so random. This is logged exception by elmah 500 HttpAntiForgery The required…
General Electric
  • 1,176
  • 3
  • 21
  • 44
40
votes
5 answers

POST a form array without successful

I'm developing an ASP.NET MVC 5 web with C# and .NET Framework 4.5.1. I have this form in a cshtml file: @model MyProduct.Web.API.Models.ConnectBatchProductViewModel @{ Layout = null; }
VansFannel
  • 45,055
  • 107
  • 359
  • 626
40
votes
3 answers

ASP.NET MVC 5 renders different bool value for hidden input

Given the following viewmodel: public class FooViewModel { public bool IsBoolValue { get; set; } } and this view: The output of the hidden…
Jason Evans
  • 28,906
  • 14
  • 90
  • 154
1 2 3
99
100