2,487 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
0
answers
52
views
Using [FromQuery] with a .NET controller for an optional boolean query string parameter where presence alone should set it
.NET has [FromQuery] to get query parameters on the path.
For instance my/foo?bar=1 maps to:
public class MyController : Controller
{
[HttpGet]
public async Task<Whatever> Foo([FromQuery]...
1
vote
1
answer
83
views
Accept enum parameter from HTTP header in controller action in ASP.NET Core
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:
public enum MyEnum
{
[EnumMember(Name = "VALUE-1")...
4
votes
1
answer
113
views
Minimal API: Dictionary<string, string> always null when sending data with IFormFile via multipart/form-data
I’m using ASP.NET Core Minimal API. I have an endpoint where I want to receive an IFormFile along with a Dictionary<string, string> property in the same request. I set the Accepts<...
0
votes
0
answers
74
views
ASP.NET MVC model binding FormData with arrays (with bracketed indexes)
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 object.
So this:
MyItem[0].MyId=1321&...
0
votes
1
answer
123
views
Model binding fails silently when using Razor pages (HTTP 400)
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 ...
-1
votes
2
answers
156
views
ASP.NET Core Web API [NULL vs UNDEFINED]
In my HTTP controller using model binding, how can I determine if a request model property, is NULL because it was explicitly set to NULL by the API client, or is NULL because it was missing in the ...
0
votes
0
answers
50
views
How to globally reject null for non-nullable reference types in ASP.NET Core 9 Web API with System.Text.Json?
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 certain properties as non‐nullable, ...
0
votes
1
answer
94
views
entire DTO is null on invalid property value instead of just that property
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 TimeOnly.
When I ...
1
vote
1
answer
73
views
How to bind an axios request that contains an array of files to an ASP.NET Core model that contains a List<IFormFile> variable
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, however List<IFormFile> ...
0
votes
2
answers
93
views
Why does one ASP.NET Core route use a slash (/) for parameters while another uses a query string (?)?
Program.cs
app.MapControllerRoute(
name: "index",
pattern: "{controller=Home}/{action=Index}/{id?}"
);
app.MapControllerRoute(
name: "read",
pattern: &...
0
votes
1
answer
106
views
Razor Pages Binding a List<t> to HTML Table
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 ServProdModel and a bound ...
1
vote
1
answer
200
views
ASP.NET undesirable model binding issue - not getting all the data bound
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 ...
0
votes
1
answer
171
views
How to bind in WinUI 3 nested template binding to the view model?
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 ...
0
votes
1
answer
56
views
Modelstate validation failed unexpectedly even with proper data passed from view
I have a simple viewmodel,
public class AuthenticateViewModel
{
[Required]
public string Email { get; set; }
[Required]
[DataType(DataType.Password)]
public string Password { get; ...
0
votes
1
answer
158
views
Facing a problem with model binding and handling object in my ASP.NET Core MVC application
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 ...