Questions tagged [asp.net-mvc-5.1]

ASP.NET MVC 5.1 is a minor upgrade from the fifth version of the ASP.NET Model-View-Controller platform for web applications

Only use this tag if it address specific issue with the new features from this release:

  • Attribute routing improvements
  • Enum support in views
  • Bootstrap support for editor templates
  • Unobtrusive validation for MinLengthAttribute and MaxLengthAttribute
  • Supporting the ‘this’ context in Unobtrusive Ajax

Or if you have issues with the breaking changes introduced:

  • (Ambiguities in) Attribute Routing
  • Scaffolding MVC/Web API into a project with 5.1 packages
  • Syntax Highlighting for Razor Views in Visual Studio 2013
  • Type Renames
    • IDirectRouteProvider -> IDirectRouteFactory
    • RouteProviderAttribute -> RouteFactoryAttribute
    • DirectRouteProviderContext -> DirectRouteFactoryContext

partly copied and redacted based on the release notes

Release notes on asp.net MVC site

302 questions
97
votes
31 answers

The type 'Expression<>' is defined in an assembly that is not referenced

In ASP.NET MVC 4.5.2 Framework, after typing @Html.LabelFor() or @Html.EditorFor() in a view, I'm getting this error: The type 'Expression<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Core,…
mansoor
  • 1,553
  • 1
  • 13
  • 18
93
votes
11 answers

How can I fix assembly version conflicts with JSON.NET after updating NuGet package references in a new ASP.NET MVC 5 project?

I created a new ASP.NET MVC 5 web project in VS 2013 (Update 1) then updated all NuGet packages. When I build the project, I get the following warning: warning MSB3243: No way to resolve conflict between "Newtonsoft.Json, Version=6.0.0.0, …
Jim Lamb
  • 25,355
  • 6
  • 42
  • 48
71
votes
5 answers

Html.EnumDropdownListFor: Showing a default text

In my view I have a enumdropdownlist (a new feature in Asp.Net MVC 5.1). @Html.EnumDropDownListFor(m => m.SelectedLicense,new { @class="form-control"}) If I execute the above code I get dropdownlist for my following enum. public enum…
Cybercop
  • 8,475
  • 21
  • 75
  • 135
39
votes
3 answers

ASP.NET MVC 5 error handling

We want to handle 403 errors, 404 errors, all errors due to a MySpecialDomainException and provide a default error page for all other errors (including errors in the IIS configuration!). All errors should return proper Razor views, it would be very…
D.R.
  • 20,268
  • 21
  • 102
  • 205
37
votes
1 answer

MVC 5.1 Razor DisplayFor not working with Enum DisplayName

I have the following entity (domain) object and model that contain an enum. The display name appears correctly and works for a EnumDropdownList but for some reason not for the DisplayFor helper, all that is shown is the actual enum name. Not sure…
devfunkd
  • 3,164
  • 12
  • 45
  • 73
31
votes
1 answer

How do I properly register AutoFac in a basic MVC5.1 website?

AutoFac has recently been updated for MVC 5.1 but at the time of writing I find that the documentation is lacking (especially for a simple example). I would like to inject dependencies into MVC Controllers and register my own implementations for…
DanAbdn
  • 7,151
  • 7
  • 27
  • 38
29
votes
4 answers

How to include TypeScript files when publishing?

I have an MVC 5.1 web application where I have recently started using TypeScript. I want to use sourcemapping, so I have included both the .ts, .js and .js.map-files in the project. When I publish the application (to e.g. file system or Azure), only…
Geir Sagberg
  • 9,632
  • 8
  • 45
  • 60
28
votes
4 answers

MVC Bundling and Minification: converts embedded images to to URL paths

In my MVC5.1 project I'm using bundling and minification with CSS rewriting transformation: styleBundle.Include("~/Content/Site.css", new CssRewriteUrlTransform()); bundles.Add(styleBundle); CssRewriteUrlTransform converts image paths relative to…
trailmax
  • 34,305
  • 22
  • 140
  • 234
25
votes
5 answers

Request.Files.Count always 0 while uploading image in MVC 5

I have a Post controller on a model with some string fields and an image. Exact identical code works on MVC4 but in MVC 5 the Request.Files.Count is always 0 My model has byte[] for image rather than HttpPostedFileBase My View: @using…
indichimp
  • 1,152
  • 2
  • 13
  • 22
25
votes
6 answers

When performing post via ajax, Bad Request is returned instead of the JSON result

Javascript jqXHR = $.ajax({ url: $frm.attr("action"), type: "POST", dataType: "json", cache: false, headers: headers, contentType: "application/json;charset=UTF-8", data: ko.mapping.toJSON(data, map), beforeSend: function(x) { if (x &&…
ridermansb
  • 10,779
  • 24
  • 115
  • 226
23
votes
4 answers

Displaying DateTime picker instead of Date picker in ASP .NET MVC 5.1/HTML 5 specific

I write application in ASP .NET MVC 5.1 I have a field: [DisplayName("Date of Birth")] [DataType(DataType.Date)] public DateTime BirthDate { get; set; } and then in View
@Html.LabelFor(model =>…
Yoda
  • 17,363
  • 67
  • 204
  • 344
19
votes
2 answers

MVC5 and Bootstrap3: Html.EditorFor wrong class? How to change?

I just noticed that MVC 5 is using a different class for input fields when using EditorFor. I think its from a lower version of bootstrap, so the current class doesn't really add up. I'm talking about this:
Dominic
  • 928
  • 3
  • 9
  • 19
18
votes
3 answers

Multiple controller types were found that match the URL. This can happen if attribute routes on multiple controllers match the requested URL

...guess I'm the first to ask about this one? Say you have the following routes, each declared on a different controller: [HttpGet, Route("sign-up/register", Order = 1)] [HttpGet, Route("sign-up/{ticket}", Order = 2)] ... you could do this in MVC…
15
votes
2 answers

How to create ApplicationUser by UserManager in Seed method of ASP .NET MVC 5 Web application

I can create users in the old way: var users = new List { new ApplicationUser{PasswordHash = hasher.HashPassword("TestPass44!"), Email = "informatyka4444@wp.pl", UserName = "informatyka4444@wp.pl", …
Yoda
  • 17,363
  • 67
  • 204
  • 344
15
votes
3 answers

How to force WebAPI to use JSON.net 6.0.3 instead of 4.5?

After adding WebAPI and register it in Global.asax. We find our web app breaks at this line: Line 17: GlobalConfiguration.Configure(WebApiConfig.Register); Error message: Could not load file or assembly 'Newtonsoft.Json,…
Blaise
  • 21,314
  • 28
  • 108
  • 169
1
2 3
20 21