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
2,464
questions
1
vote
0
answers
10
views
Model Parameter is Null in POST Method on Azure VM but Works Locally
I have an ASP.NET Core application that works correctly on my local machine but encounters an issue when deployed to an Azure Windows VM. Specifically, the model passed as a parameter to the POST ...
1
vote
1
answer
16
views
ASP.NET Web Api Model Binding From A Stream
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
[...
0
votes
1
answer
41
views
How to bind nested FromForm data with List<IFormFile> to model form Javascript
I have a javascript form with a bunch of data that is appended to a form as follows:
this.historicalPreprintDocs.forEach((round, index) => {
form.append(`...
0
votes
0
answers
68
views
CSP report endpoint problem in ASP.NET Core
I'm working on an ASP.NET Core application where I need to handle Content Security Policy (CSP) violation reports. I have set up a CSP header to report violations to a specific endpoint and created a ...
0
votes
2
answers
75
views
I receive null after Model Binding
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
<form asp-action="Create" method=&...
0
votes
1
answer
24
views
How to send some ids from the form to the controller using viewmodel
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 ...
0
votes
1
answer
46
views
ASP.NET Core MVC : model binding issues - view is passing null values to the action method of the controller
The form field property of my view is sending null values to the controller.
I have this view model:
public class CreateProductViewModel
{
public List<TblProduct> getCreatedProduct { get; ...
0
votes
0
answers
45
views
How to create a custom model binder attribute
I am not sure if this is even possible but I have a model as follows:
public class AddDocumentDTO
{
[Required]
[CustomAccessTokenAttribute]
public required User Uploader {get; set;}
...
0
votes
2
answers
94
views
How to utilize FromBody and FromRoute in the same model with model binding
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:
[HttpPost("{state_id}/StateContact")...
0
votes
0
answers
38
views
Binding a nested object using FromForm
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 ...
0
votes
0
answers
34
views
How to manually handle model deserialization errors similar to data annotations
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 ...
1
vote
1
answer
77
views
Is there a way to make the ASP.NET Core model binder set properties with private setters?
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 ...
0
votes
1
answer
107
views
C# XML ModelBinding - ASP.NET Core 8 Web API - required field not found
I want to bind this XML:
<?xml version="1.0" encoding="UTF-8"?>
<D:propfind xmlns:D='DAV:' xmlns:A='http://apple.com/ns/ical/'
xmlns:C='urn:ietf:params:xml:ns:caldav'&...
0
votes
1
answer
58
views
How to enable escaped JSON string parsing in asp.net core?
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\...
0
votes
0
answers
19
views
How to use Databinding?
(https://i.sstatic.net/lxmAJ.jpg)(https://i.sstatic.net/Kxn7k.jpg)(https://i.sstatic.net/kNyBJ.jpg)(https://i.sstatic.net/J6E0z.jpg)
I tried to learn a lot through videos but failed. I want you to ...