The custom binding class needs to inherit form IModelBinder. Here we capture the current request and extract the Form fields individually. Then we can manipulate these fields any way we like.
I have a Web API 2 project and an other project, in which I have my Model classes and a BaseModel that is a base for all Models, as following,
public class BaseModel
{
public string UserId { get; set; }
}
All the other models are derived from…
I would like my model binding to be case insensitive.
I tried manipulating a custom model binder inheriting from System.web.Mvc.DefaultModelBinder, but I can't figure out where to add case insensitivity.
I also took a look at IValueProvider, but I…
This is related to this question, but in this case it's not something I am returning but rather the model binding. I am using Postmark to handle incoming emails, which posts to a page with a JSON payload.
I have a model as below and an action that…
I'm sure someone has asked this before, but I'm struggling to find where.
I'm using Ninject to remove dependencies from my controllers, along with a repository design pattern.
As I understand it, one of the benefits of this approach is that I can…
Can I do something like this?
[HttpPost]
public ActionResult Index(WizardViewModel wizard, IStepViewModel step)
{
Where I have the following in my global.asax.cs application_start
ModelBinders.Binders.Add(typeof(IStepViewModel), new…
I am trying to bind a string route parameter to Enum Type like below
public static async Task Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "ValidateKey/{keyType}/{key}")]HttpRequestMessage req, KeyType…
I'm building a dynamic form creator in .net core. A "form" will consist of many different form elements. So the form model will look something like this:
public class FormModel {
public string FormName {get;set;}
public List…
It would be handy to limit the scope of a custom model binder for just a specific controller action method or its entire controller. Hanselman wrote a sentence that implied alternative locations for custom model binder registration but never seemed…
I got a model like this:
public class MainModel
{
public string Id {get;set;}
public string Title {get;set;}
public TimePicker TimePickerField {get;set;}
}
TimePicker is an inner model which looks like this:
public class TimePicker
{
…
I'm currently converting a ASP.NET library to ASP.NET Core that's heavy on Model Binding, and one issue I'm unable to resolve is that for cases where a model binder wants to try and get values via Value Providers both from (From)Query and…
I am using a custom model binder in order to put some custom logic in my model Binding.
Here's my DTOs:
public class TaskDto
{
public int Id { get; set; }
[MaxLength(100), Required]
public string Name { get; set; }
public…
I have written a custom model binder for List in my MVC project however I am now stuck in how to get this binder to validate against my DataAnnotations validation attributes.
I have found some posts on the interwebs that talk about similar…
I'm looking for advice on a decent pattern for dropdown list selection and persistence of the selection with POCO EF please.
I have a list of IEnumerable in my view model where Country is a POCO loaded via EF. There is an Address property…
I apologise for the amount of code I have included. I've tried to keep it to a minimum.
I'm trying to have a Custom Validator Attribute on my model as well as a Custom Model binder. The Attribute and the Binder work great seperately but if I have…
I need to create a dynamic input form based on a derived type but I cannot get complex properties bound properly when passed to the POST method of my controller. Other properties bind fine. Here is a contrived example of what I have:
Model
public…