338 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
0
answers
73
views
ASP.NET Web API - Model binder validation property name
I have a basic ASP.NET Web API project. When I send a request, the serialization is done using System.Text.Json. However, when I send a non-valid json, for example text instead of number, it returns a ...
0
votes
0
answers
77
views
ASP.NET Core 6 Web API : ModelBinder failed to convert time string into datetime
I have two ASP.NET Core 6.0 Web API methods with the same parameter type:
[HttpPost]
public IActionResult methodOne([FromForm] DtoWithDateTime dtoWithDateTime )
[HttpPost]
public IActionResult ...
0
votes
2
answers
3k
views
Minimal API requires TryParse() on input model despite ModelBinder
I'm trying to implement a single ModelBinder for all my DTOs:
public class MyModelBinder : IModelBinder
{
public Task BindModelAsync(ModelBindingContext bindingContext) {
var queryDto = ...
0
votes
2
answers
92
views
ASP.NET Core 7 when receiving an object data from Http POST binding invalid properties
When receiving an object from a client on a Http API endpoint - and that object comes in as a C# object (FromBody) - is there any way to detect if the client has added a property that is not part of ...
0
votes
2
answers
810
views
How do I add a custom ModelBinder to a custom type inside a C# class?
I have a WarehouseDTO class with a Name field of a custom type called CustomString. I'm trying to create a custom ModelBinder to bind the type when it is passed from the front end via the controller. ...
0
votes
1
answer
1k
views
C# model binding with auto increment column
I got below model and i would like to create List when its instantiated.
My question is is there a way i pass only Col1 and Col2 and rowID gets generated automatically, like autoincrement.
Please note,...
1
vote
0
answers
169
views
CustomModelBinder on properties of a Dto class
I have a DtoClass which has properties of a specific class, I don't want to have a CustomModelBinder for the DtoClass but for the class of its properties; I am using asp.net core 3.1.
My ModelBinder ...
1
vote
0
answers
123
views
ModelBinder in .Net Core
I use ASP.NET Core 5, I want to create a custom model binder for every property that ends with ParenteseIcon and when I got the data in the server property will be like this (Client user => Value ...
0
votes
1
answer
660
views
AspNetCore API ModelBinder could not find a value
I'm trying to pass an array of objects ( models ) to http post request but my API controller throws an error:
Could not find a value in the request with name '' for binding
parameter 'list' of ...
0
votes
2
answers
747
views
C# - Model is always getting its default values
I have an ASP.Net Core 2.1 application.
Below is my DTO
public class Movie
{
public int Id { get; set;}
public bool IsSpecial {get; set;}
public IEnumerable<Ticket> Tickets { get; set; ...
0
votes
0
answers
489
views
asp.net core WebAPI get subset of Generic Request Object
I am new into asp.net core webAPI.
I have created a Controller method that taken a request object.
[HttpPost]
[Route("/api/DoWork")]
[ValidateModelState]
public virtual IActionResult ...
2
votes
1
answer
3k
views
Apply [FromBody] attribute to all controller actions in .net core
Having a simple .NET Core API with your models posted as JSON in request body, how to have [FromBody] attribute applied to all controller methods?
[Route("api/simple")]
public class SimpleController :...
2
votes
1
answer
179
views
Injecting Class into IModelBinder using Ninject
I have the following Custom Model Binder:
public class AllowAndSanitizeHtmlBinder : IModelBinder
{
// initialize HtmlSanitizer (I want this to be injected)
private HtmlSanitizer ...
0
votes
1
answer
4k
views
MVC Controller handle POSTed JSON as a string
I have a 3rd party app making POST submissions to my site with application/json in the body. I can capture a strongly typed object as:
public string Postback([FromBody]MyResponse myResponse)
My ...
0
votes
1
answer
526
views
How to disable model binding for one action method in asp.net mvc
We are using custom model binders, how to disable model binding for one action method, so that i can directly post data from angular http post request,
I have taken different/new class as parameter ...