Skip to main content

Questions tagged [model-binding]

Model Binding is a feature of ASP.NET MVC, and (from .NET 4.5) ASP.NET WebForms, that simplifies controller actions by using the request data to create strongly typed objects.

model-binding
Filter by
Sorted by
Tagged with
0 votes
1 answer
117 views

.NET has [FromQuery] to get query parameters on the path. For instance my/foo?bar=1 maps to: ...
Keith's user avatar
  • 157k
1 vote
1 answer
99 views

In my ASP.NET Core application, I want to expose an API endpoint that takes a single input parameter, which is of the following enum type: ...
Maxime Rossini's user avatar
4 votes
1 answer
144 views

I’m using ASP.NET Core Minimal API. I have an endpoint where I want to receive an IFormFile along with a ...
Dmytro Kotenko's user avatar
0 votes
0 answers
85 views

Using model binding, ASP.NET MVC can take FormData from a form with repeating elements, signified by the use of indexes in square brackets, and populate a .NET ...
Mr Rusty's user avatar
0 votes
1 answer
129 views

UPDATE: I changed the form a little bit and added some code to try and get the script to sync with the form. I also checked the payload and saw that only 2 out of 4 fields are being submitted to the ...
kevin29's user avatar
  • 103
-1 votes
2 answers
199 views

In my HTTP controller using model binding, how can I determine if a request model property, is NULL because it was explicitly set to ...
olfek's user avatar
  • 3,522
0 votes
0 answers
67 views

Background I have an ASP.NET Core 9 Web API project with [nullable reference types] enabled (<Nullable>enable</Nullable>). In my request DTOs, I declare ...
Tom's user avatar
  • 497
0 votes
1 answer
110 views

I’m building a simple student ASP.NET Core 8.0 Web API and have a controller action that accepts a JSON body bound to a DTO. My DTO contains properties of various types, like int and ...
user25038396's user avatar
1 vote
1 answer
90 views

I have started to take advantage of Axios header option multipart/form-data so I can go utilize Typescript objects for my requests to bind to my ASP.NET Core models,...
Qiuzman's user avatar
  • 1,873
0 votes
1 answer
121 views

I am using ASP.NET Core 8.0 with Razor Pages (not MVC). Webpage has a table where the prices of services offered can be modified as shown here: I have created a model class ...
NP3's user avatar
  • 664
1 vote
1 answer
257 views

Model binding in ASP.NET is not binding all the received data if the request contains the parmeter object name. I don't know how to describe it in a better way, but the sample I'm providing will make ...
Marko's user avatar
  • 1,670
0 votes
1 answer
206 views

I have a winui3 app that has responsive UI for screen like desktop, tablet and mobile. I have three template for that. and I used content Control inside the page within the Content Control there is ...
Abdul Saboor Habibi's user avatar
0 votes
1 answer
168 views

I am facing a problem with model binding in my ASP.NET Core MVC application. Currently, the MVC template is the default one. When I write an HTTP POST method, after a user submits feedback, it is not ...
Muhammad Munib Nawaz's user avatar
0 votes
1 answer
466 views

I have a security problem in my app. When somebody sends wrong json to my endpoint (for example, pass type string instead if int), my API displays json deserialisation exception: ...
JamesBondCaesar's user avatar
1 vote
0 answers
98 views

I have PostgreSQL server and a C# app that uses EF Core as an ORM. This is the scenario I have - main model: ...
Yulian Dimitrov's user avatar
0 votes
0 answers
112 views

Given the following two model classes: ...
Mark Good's user avatar
  • 4,355
0 votes
1 answer
64 views

I have an example class like this: public class TestClass { [Precision(18,2)] public decimal? Amount { get; set; } } In the frontend, ...
Topik's user avatar
  • 41
0 votes
1 answer
67 views

I have the following method in a controller decorated with [ApiController] attribute: ...
killswitch's user avatar
0 votes
1 answer
71 views

In my controller, I want to update FileContent in Image model. But ModelState says it's null. ...
Hiroco's user avatar
  • 55
1 vote
1 answer
110 views

I am trying to get the raw POSTed key value pairs for additional processing logic later on in my action. I have a class like this: ...
SventoryMang's user avatar
  • 10.5k
1 vote
1 answer
101 views

I get the error mentioned in the title. Important The form submits the data into the database successfully, but then it tries to submit again with another query that tries to simultaneously insert a ...
WorkingProgrammer's user avatar
0 votes
1 answer
80 views

By default when you post to an ASP.NET Core MVC method, the model binder/json converter will validate any validation attributes or custom validation logic on the full model when converting from JSON ...
SventoryMang's user avatar
  • 10.5k
3 votes
2 answers
735 views

When someone calls my api endpoint (Minimal API), I would like to pull a dictionary from the query string. I have the following query parameter struct for my Minimal API endpoint (simplified for this ...
David Poxon's user avatar
  • 2,543
0 votes
1 answer
103 views

When I submit the form, the animal weight entered as a decimal is posted as a whole number. 4.5 or 4,5 comes to model as 45. What can I try next? This is the entity class: ...
umut günenç's user avatar
1 vote
1 answer
24 views

Im trying to send a http post request from Action1 to Action2 and instead of sending the payload as string Im sending it as stream for performance. Im getting the error. Unsupported Media Type ...
VJAI's user avatar
  • 32.9k
0 votes
1 answer
70 views

I have a javascript form with a bunch of data that is appended to a form as follows: ...
Qiuzman's user avatar
  • 1,873
0 votes
2 answers
85 views

I receive variable with null values after model binding. What might be wrong here? Title is null, content is null after form submitting. Create.cshtml ...
Lisbeth Edvinsen's user avatar
0 votes
1 answer
27 views

I have an index page in my .net mvc program, which has two parts for displaying contacts and adding contacts. Contacts and groups in my database have a many-to-many relationship. I have been able to ...
esmail's user avatar
  • 11
0 votes
1 answer
59 views

The form field property of my view is sending null values to the controller. I have this view model: ...
Win Sunday's user avatar
0 votes
0 answers
60 views

I am not sure if this is even possible but I have a model as follows: ...
Qiuzman's user avatar
  • 1,873
1 vote
2 answers
1k views

I am trying to utilize FromRoute for one property of a model and FromBody for the remaining items as the API is accepting JSON. My code is as follows: ...
Qiuzman's user avatar
  • 1,873
0 votes
0 answers
245 views

I have been able to properly bind a complex object to my model from a form but I am struggling for one item in particular and it is not making sense why it wont work as I have repeated the same logic ...
Qiuzman's user avatar
  • 1,873
0 votes
0 answers
102 views

I have previously been tasked with trying to submit json data and files to a web api shown here in this problem. The issue is I do not want to create a custom model binder for every instance this ...
Qiuzman's user avatar
  • 1,873
1 vote
1 answer
180 views

I use ASP.NET Core minimal APIs and I try to have my view-models (where incoming client data gets mapped to) use private setters for their properties. But I see that the binding stops working once I ...
user2173353's user avatar
  • 4,790
0 votes
1 answer
367 views

I want to bind this XML: ...
user2325110's user avatar
0 votes
1 answer
197 views

When I send a request to the endpoint with an escaped JSON string it throws an exception "JSON value could not be converted to Test.TestClass . Path: $ | LineNumber: 0 | BytePositionInLine: 90.\r\...
Lakshin Karunaratne's user avatar
0 votes
1 answer
58 views

I'm trying to write a custom model binder for a .NET API Endpoint. I have a Post Endpoint with one parameter of type ICar. I ...
clfaster's user avatar
  • 1,904
0 votes
1 answer
121 views

When I send the model back to the Controller, the model instance returns with all properties null. This is the ViewModel with some properties, including a SelectList and a model instance. ...
LeoDev's user avatar
  • 15
0 votes
1 answer
208 views

I have run into a problem where post requests in my CRUD app result in data loss due to simply forgetting to add a hidden field inside my <form> tags. For ...
kj49's user avatar
  • 75
-1 votes
1 answer
72 views

I have a List as a field in a Model class named "Person" enter image description here I have enabled Custom Person Model Binder globally in Program.cs file enter image description here Since ...
Vivek's user avatar
  • 1
1 vote
3 answers
1k views

Using a model binder it is possible to pass a NULL complex type to a controller endpoint. This solution does not work for all controller endpoints, rebuilding the model is also not straight forward. ...
user avatar
0 votes
2 answers
757 views

I have an ASP.NET Core controller with multiple action methods. Each action method has an {id} path parameter and do the following in almost every request: ...
lightning_missile's user avatar
0 votes
1 answer
1k views

How do I keep a Model alive across multiple actions and views? So that no parameter value is lost in between. I suspect I am doing some basic error in Model binding. For example, I have a Model <...
somnath's user avatar
  • 41
0 votes
0 answers
106 views

I have created a WCF service that accepts, for example, this json: ...
kbbucks's user avatar
  • 148
1 vote
1 answer
235 views

I am using ASP.NET MVC for a small website. I can't find a way to bind multiple file inputs into one IEnumerable. I have the following inputs in my view: ...
Mladen Nikolov's user avatar
0 votes
1 answer
274 views

When using Razor Pages 7 I have this in the code-behind file: ...
lonix's user avatar
  • 22.6k
2 votes
2 answers
5k views

I have an endpoint on my ASP.NET Core Web API that looks something like this: ...
Anna Aimeri's user avatar

1
2 3 4 5
50