The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value

I have the following code in my HomeController: public ActionResult Edit(int id) { var ArticleToEdit = (from m in _db.ArticleSet where m.storyId == id select m).First(); return View(ArticleToEdit); } [ValidateInput(false)] [AcceptVerbs(HttpVerbs.Post)] public ActionResult Edit(Article ArticleToEdit) { var originalArticle = (from m in _db.ArticleSet where m.storyId == ArticleToEdit.storyId select m).First(); if (!ModelState.IsValid) return View(originalArticle); _db.ApplyPropertyChanges(originalArticle.EntityKey.EntitySetName, ArticleToEdit); … Read more

How can I add a class attribute to an HTML element generated by MVC’s HTML Helpers?

ASP.NET MVC can generate HTML elements using HTML Helpers, for example @Html.ActionLink(), @Html.BeginForm() and so on. I know I can specify form attributes by creating an anonymous object and pass that object for the (fourth in this case) htmlAttributes parameter where specifying an id for the element: Html.BeginForm(“Foo”, “Bar”, FormMethod.Post, new { id = “MyForm”}) … Read more

Role-based access control (RBAC) vs. Claims-based access control (CBAC) in ASP.NET MVC

What are the main benefits of using CBAC vs. RBAC? When is it better to use CBAC and when is it better to use RBAC? I’m trying to understand the general concepts of the CBAC model but the general idea is still not clear for me. 12 Answers 12

ASP.NET MVC Html.ValidationSummary(true) does not display model errors

I have some problem with Html.ValidationSummary. I don’t want to display property errors in ValidationSummary. And when I set Html.ValidationSummary(true) it does not display error messages from ModelState. When there is some Exception in controller action on string MembersManager.RegisterMember(member); catch section adds an error to the ModelState: ModelState.AddModelError(“error”, ex.Message); But ValidationSummary does not display this … Read more

renderpartial with null model gets passed the wrong type

I have a page: <%@ Page Inherits=”System.Web.Mvc.View<DTOSearchResults>” %> And on it, the following: <% Html.RenderPartial(“TaskList”, Model.Tasks); %> Here is the DTO object: public class DTOSearchResults { public string SearchTerm { get; set; } public IEnumerable<Task> Tasks { get; set; } and here is the partial: <%@ Control Language=”C#” Inherits=”System.Web.Mvc.ViewUserControl<IEnumerable<Task>>” %> When Model.Tasks is not null, … Read more

MVC4 DataType.Date EditorFor won’t display date value in Chrome, fine in Internet Explorer

I’m using the DataType.Date attribute on my model and an EditorFor in my view. This is working fine in Internet Explorer 8 and Internet Explorer 9, but in Google Chrome it is showing a date picker and instead of displaying the value it just displays “Month/Day/Year” in faded gray text. Why won’t Google Chrome display the value? Model: [DataType(DataType.Date)] … Read more