You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+29Lines changed: 29 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,3 +59,32 @@ public class MyController : Controller<MultipartViewModel>
59
59
}
60
60
}
61
61
```
62
+
63
+
### Binding parameters to a strongly typed model
64
+
65
+
Instead of searching through the `Parameters` list manually, you can bind the multipart form parameters to a strongly typed model the same way as for a regular query/form/JSON request. Inherit your model from `MultipartModel` (which exposes `Files`) and add your own properties:
66
+
67
+
```csharp
68
+
publicclassUploadModel : MultipartModel
69
+
{
70
+
publicstringTitle { get; set; }
71
+
72
+
publicintCount { get; set; }
73
+
}
74
+
```
75
+
76
+
The parameters are parsed into the model properties automatically (the same parser as `Simplify.Web` query/form binding is reused, so `[BindProperty]`, `[Exclude]`, `[Format]`, `IList<T>` properties and validation attributes are all supported), while the uploaded files remain accessible via `Model.Files`:
Copy file name to clipboardExpand all lines: src/Simplify.Web.Multipart/CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,18 @@
4
4
5
5
### Added
6
6
7
+
-`MultipartModel` base class which exposes the uploaded `Files` and allows binding the multipart form parameters to a strongly typed model (reusing the `Simplify.Web` model parser, so `[BindProperty]`, `[Exclude]`, `[Format]`, `IList<T>` properties and validation attributes are supported)
7
8
- .NET 10.0 explicit support
8
9
9
10
### Removed
10
11
11
12
- .NET 6.0 explicit support
12
13
- .NET 4.8 explicit support
13
14
15
+
### Changed
16
+
17
+
-`MultipartViewModel` now inherits from `MultipartModel` (fully backward compatible, still exposes the raw `Parameters` list)
0 commit comments