controller – Question about ASP.NET MVC & a form post using HTTP-POST – Education Career Blog

I’ve got a standard ASP.NET MVC form post.


<% using (Html.BeginForm<CommentController>(c => c.Create())) { %>    
<% } %>

(and in the controller)

public ActionResult Create(Comment comment)
{ .. }

Now, how can i make it so that i IGNORE certain values, like the ID or CreatedOn properties, that might exist in the Comment object?

Is there a way i can define an exclusion/black list?


Use the BindAttribute with the Exclude tag

public ActionResult Create( Bind(Exclude="ID, CreatedOn")Comment comment )


Whatever inputs you have within your form HTML will be passed in with the submission by default.

Sorry I don’t have an answer off the top of my head, but I’d start by looking into some possible jQuery plugins and/or some AJAX filtering mechanisms.

Leave a Comment