नोट
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप साइन इन करने या निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
| Value | |
|---|---|
| Rule ID | ASP0003 |
| Category | Usage |
| Fix is breaking or non-breaking | Non-breaking |
Cause
A route handler delegate includes a parameter that has a [Bind] attribute.
Rule description
Route handler endpoints only support a subset of MVC attributes such as [FromRoute], [FromBody], etc. Unsupported attributes are ignored and result in unexpected binding behavior. For example, the following code results in an analyzer warning:
app.MapGet("/todos/{id}", ([Bind] int id) => new Todo { Id = id });
How to fix violations
To fix a violation of this rule, make sure that the endpoint uses one of the allowed model binding attributes.
app.MapGet("/todos/{id}", ([FromRoute] int id) => new Todo { Id = id });
When to suppress warnings
Do not suppress a warning from this rule. An incorrect model binding setup can result in unexpected behavior when resolving parameters at runtime.
ASP.NET Core