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 custom model binder inheriting from DefaultModelBinder. What I want it to do is to set a property on the model, that can't be resolved by the DefaultModelBinder. It looks like this:
public class FooModelBinder : DefaultModelBinder {
…
I have incoming requests (from Facebook for Credits handling) on a specific action which will have have different contents, so I have different model classes to handle that.
This is my action:
public ActionResult…
I need to implement a [HttpPost] web api with same route/uri, but more than 10 different combinations of parameters in json body. In which some parameters are null in some case but required in another case. As I am migrating an already deployed…
I am trying to make a binder for an abstract class. The binder decides which implementation of the class to use.
public abstract class Pet
{
public string name { get; set; }
public string species { get; set; }
abstract public string talk…
I'm trying to implement custom binder to allow comma separated list in query string. Based on this blog post and official documentation I have created some solution. But instead of using attributes to decorate wanted properties I want to make this…
I have a dynamic list of dynamic lists, which have s that need to be POSTed to an MVC controller/action and bound as a typed object. The crux of my problem is I can't figure out how to manually pick out arbitrary POSTed form values in my…
I am trying some paging and sorting stuffs in ASP.net core MVC 6 application. But when I pass array like query string MVC action unable to parse it to list.
Query String looks like…
I'm building a custom model binder in ASP.NET, and in my post variables I have couple of them with same name.
Example:
website.com?person=1&person=3&person=6
Currently I'm using request.Form.Get("name") syntax to get variables, but it returns…
I'm creating a few custom binders for complex types in my Model. My model is composed of objects that have their own separate binders. I want the base object to do its dirty work and then populate the complex object it encapsulates by passing off…
I'm trying to figure out model binding in current mvc6 (visual studio 2015 release candidate).
This is what my code looks like so far:
public class MyObjectModelBinder : IModelBinder
{
public Task…
How can I write custom model binder for complex model with collection of polymorphic objects?
I have the next structure of models:
public class CustomAttributeValueViewModel
{
public int? CustomAttributeValueId { get; set; }
public int…
I have a struct which works much like the System.Nullable type:
public struct SpecialProperty
{
public static implicit operator T(SpecialProperty value)
{
return value.Value;
}
public static implicit operator…
Given an action like:
public ActionResult DoStuff([CustomAttribute("foo")]string value) {
// ...
}
Is there any way to resolve the instance of value's CustomAttribute within a ModelBinder? I was looking at the MVC sources and chances are I'm just…
I have my application and from the security testing team I got a bug reported about the possibility for a user to inject malicious code from our forms inputs.
The application is developed in ASP.NET MVC4, .NET 4.5 and EF 5.
The attack being tested…