asp.net-mvc-5.1

MVC 5.1 Razor DisplayFor not working with Enum DisplayName

蓝咒 提交于 2019-11-27 07:13:58
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 what I am missing, asp.net MVC 5.1 added display name support for this so I shouldn't need to create my own helper methods. See: https://aspnet.codeplex.com/SourceControl/latest#Samples/MVC/EnumSample/EnumSample/Models/Enums.cs public class Addon { public int Id { get; set; } public AddonType AddonType { get; set; } public string Name { get; set; }

ASP.NET MVC 5 error handling

我们两清 提交于 2019-11-26 22:06:53
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 nice to have an ErrorController in front of the views. E.g. something like this: public class ErrorController : Controller { public ViewResult NotFound () { return View(); } public ViewResult Forbidden () { return View(); } public ViewResult Default () { var ex = ObtainExceptionFromSomewhere(); if(ex is MySpecialDomainException) return View(

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

萝らか妹 提交于 2019-11-26 18:26:42
问题 ...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 5.0 with the same code except for the Order parameter. But after upgrading to MVC 5.1, you get the exception message in the question title: Multiple controller types were found that match the URL. This can happen if attribute routes on multiple

MVC 5.1 Razor DisplayFor not working with Enum DisplayName

℡╲_俬逩灬. 提交于 2019-11-26 17:37:53
问题 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 what I am missing, asp.net MVC 5.1 added display name support for this so I shouldn't need to create my own helper methods. See: https://aspnet.codeplex.com/SourceControl/latest#Samples/MVC/EnumSample/EnumSample/Models/Enums.cs public class Addon {

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

大兔子大兔子 提交于 2019-11-26 15:22:11
问题 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, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" and "Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed". When I check the web.config, however, I see that a binding redirect is in place: <dependentAssembly> <assemblyIdentity

Html.EnumDropdownListFor: Showing a default text

左心房为你撑大大i 提交于 2019-11-26 10:26:01
问题 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 LicenseTypes { Trial = 0, Paid = 1 } but by default I want my dropdownlist to have a value(custom text) and this is what I tried @Html.EnumDropDownListFor(m => m.SelectedLicense,\"Select a license\" ,new { @class=\"form-control\"}) but now the problem is when i