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
41
votes
10 answers

Retrieve the current view name in ASP.NET MVC?

I have a partial view (control) that's used across several view pages, and I need to pass the name of the current view back to the controller - so if there's e.g. validation errors, I can re-draw the original view. A workaround way to do it would be…
Dylan Beattie
  • 53,688
  • 35
  • 128
  • 197
41
votes
2 answers

How does RequireJS work with multiple pages and partial views?

I'm looking into RequireJS but I'm uncertain about some things. I understand how I can load all my dependencies with main.js. But do I need to add any logic to work with those dependencies in main.js? To me, main.js seems like a document.ready state…
Johan Alkstål
  • 5,225
  • 9
  • 36
  • 48
41
votes
10 answers

Display html within @html.actionlink with Twitter Bootstrap

I'm using Twitter Bootstrap, and trying to make my links ASP.Net MVC look nice. However, the
Mark
  • 7,778
  • 24
  • 89
  • 147
41
votes
2 answers

Uploading image in ASP.NET MVC

I have a Upload form and I want to pass my information such as an Image and some other field but I don't know how can I upload Image .. this is my controller code : [HttpPost] public ActionResult Create(tblPortfolio tblportfolio) { …
Persian.
  • 1,035
  • 3
  • 16
  • 34
40
votes
6 answers

ASP.NET MVC and text/xml content type

I want to return a View() from an action, and the resulting response should have a content type of text/xml instead of the default text/html. I have tried the following, with no success: Response.ContentType = "text/xml"; return View(); I know…
andreialecu
  • 3,639
  • 3
  • 28
  • 36
40
votes
15 answers

Should I Use TDD?

I'm the only developer in my (very small) company and I'm about to start on a medium sized ASP.NET web application for said company. I'm trying to figure out if I should learn Test Driven Development (TDD) and implement it in this application. I…
CalebHC
  • 4,998
  • 3
  • 36
  • 42
40
votes
1 answer

Real alternatives to Windows Azure PaaS (web role)?

I am looking for alternatives to the Windows Azure PaaS (Platform as a Service) offering, meeting the following requirements: The platform should provide high availability and scalability. The platform should manage/update the application server…
Börg
  • 532
  • 1
  • 4
  • 13
40
votes
20 answers

"The name 'HTML' does not exist in the current context" in MVC 3 Views

I´m starting to use "MVC 3" but I´m facing some little problems. In my Views, when I code something like this: @if(Request.IsAuthenticated) { Welcome @Context.User.Identity.Name! [ @Html.ActionLink("Log Off", "LogOff",…
outlookrperson
  • 2,761
  • 7
  • 32
  • 49
40
votes
2 answers

in a controller in asp.net-mvc how can i get information about the users browser?

I am logging errors on my asp.net-mvc site and I wanted to see if there is anyway to detect the users browser info (name, version, etc) as it seems like people are getting issue but its because they are using very old browser. This info would help…
leora
  • 188,729
  • 360
  • 878
  • 1,366
40
votes
6 answers

ASP.net MVC [HandleError] not catching exceptions

In two different application, one a custom the other the sample MVC application you get with a new VS2008 MVC project, [HandleError] is not catching exceptions. In the sample application I have: [HandleError] public class HomeController :…
Eric
40
votes
4 answers

How do I programmatically set the connection string for Entity-Framework Code-First?

I'm trying to write some code that allows me to switch between SQLCE (locally on my dev machine) and full SQL (on AppHarbor). With SQL CE, the connection string is all handled for me, but I have to construct it myself for SQL. My code so far is…
Danny Tuppeny
  • 40,147
  • 24
  • 151
  • 275
40
votes
5 answers

How do I access query string parameters in asp.net mvc?

I want to have different sorting and filtering applied on my view I figured that I'll be passing sorting and filtering params through query string: @Html.ActionLink("Name", "Index", new { SortBy= "Name"}) This simple construction allows me to sort.…
Alexander Taran
  • 6,655
  • 2
  • 39
  • 60
40
votes
5 answers

Asp.Net Mvc - How to have a "controller" in shared view

I have a shared view in my _Layout.cshtml for my header named "_Header.cshtml". I would like to display text and image from the database, so I need my controller to go in the database and return it to the _Header.cshtml. How can I do that because…
Patrick Desjardins
  • 136,852
  • 88
  • 292
  • 341
40
votes
3 answers

Razor ViewEngine HTML.Checkbox method creates a hidden input. Why?

I have written the below code on my view page; @Html.CheckBox("ChxName",true) and I got the following result;
tugberk
  • 57,477
  • 67
  • 243
  • 335
40
votes
1 answer

Using multiple membership providers within ASP.Net MVC 3 application

I am adding a new area to an existing mvc 3 razor app as an admin area for managing some settings and content. The rest of the site is currently secured by a custom provider that authenticates our clients. Now I need to authenticate some employees…
JBeckton
  • 7,095
  • 13
  • 51
  • 71
1 2 3
99
100