CommonNetFuncs.Web.Interface
3.6.1
dotnet add package CommonNetFuncs.Web.Interface --version 3.6.1
NuGet\Install-Package CommonNetFuncs.Web.Interface -Version 3.6.1
<PackageReference Include="CommonNetFuncs.Web.Interface" Version="3.6.1" />
<PackageVersion Include="CommonNetFuncs.Web.Interface" Version="3.6.1" />
<PackageReference Include="CommonNetFuncs.Web.Interface" />
paket add CommonNetFuncs.Web.Interface --version 3.6.1
#r "nuget: CommonNetFuncs.Web.Interface, 3.6.1"
#:package CommonNetFuncs.Web.Interface@3.6.1
#addin nuget:?package=CommonNetFuncs.Web.Interface&version=3.6.1
#tool nuget:?package=CommonNetFuncs.Web.Interface&version=3.6.1
CommonNetFuncs.Web.Interface
This lightweight project contains helper methods related to web interface functionality (specifically designed for MVC)
Contents
DataTableHelpers
Helpers related to handling requests from the DataTables.net JavaScript plugin.
DataTableHelpers Usage Examples
<details> <summary><h3>Usage Examples</h3></summary>
GetDataTableRequest
Parses the HttpRequest
passed by the DataTables.net API into a DataTableRequest object (included in the CommonNetFuncs.Web.Interface package)
HttpRequest request = A.Fake<HttpRequest>();
Dictionary<string, StringValues> formData = new()
{
{ "draw", new StringValues("1") },
{ "start", new StringValues("0") },
{ "length", new StringValues("10") },
{ "order[0][column]", new StringValues("1") },
{ "order[0][dir]", new StringValues("asc") },
{ "columns[1][data]", new StringValues("name") },
{ "search[value]", new StringValues("field1=value1,field2=value2") }
};
IFormCollection formCollection = new FormCollection(formData);
A.CallTo(() => request.ContentType).Returns("application/x-www-form-urlencoded");
A.CallTo(() => request.Form).Returns(formCollection);
// Using the above form data as the HttpRequest's form data...
DataTableRequest result = request.GetDataTableRequest();
// result =
// {
// Draw = 1,
// PageSize = 10,
// Skip = 0,
// SortColumns[0] = "name",
// SortColumnsDir[0] = "asc",
// SearchValues["field1"] = "value1",
// SearchValues["field2"] = "value2"
// }
GetSortAndLimitPostModel
Converts a DataTableRequest object into a SortAndLimitPostModel object (included in the CommonNetFuncs.Web.Interface package) to make REST calls from the controller easier.
DataTableRequest result = request.GetDataTableRequest();
SortAndLimitPostModel sortAndLimitPostModel = DataTableHelpers.GetSortAndLimitPostModel(result);
// Assuming the same request as before:
// sortAndLimitPostModel =
// {
// SortColumns = ["name"],
// SortColumnDir = ["asc"],
// Skip = 0,
// PageSize = 10
// }
ModelErrorHelpers
Helper for dealing with model errors captured in ASP.NET Core applications.
ModelErrorHelpers Usage Examples
<details> <summary><h3>Usage Examples</h3></summary>
ParseModelStateErrors
Convert ModelStateDictionary used by ASP.NET Core into a standard dictionary.
if (!ModelState.IsValid)
{
Dictionary<string, string?> errors = ModelErrorHelpers.ParseModelStateErrors(ModelState); // Result is a dictionary containing all of the model state errors inside of a controller call
}
SelectListItemCreation
Helpers for creating SelectListItem objects for populating select lists.
SelectListItemCreation Usage Examples
<details> <summary><h3>Usage Examples</h3></summary>
ToSelectListItem
Creates a SelectListItem based on the input values.
public class Person
{
public int Id { get; set; }
public required string Name { get; set; }
public DateTime CreatedDate { get; set; }
}
// Id and Value are different
List<Person> people = [ new() { Id = 1, Name = "Nick", CreatedDate = DateTime.Now }, new() { Id = 2, Name = "Chris", CreatedDate = DateTime.Now } ];
List<SelectListItem> peopleOptions = people.Select(x => x.Id.ToSelectListItem(x.Name)); // [ { Value = "1", Text = "Nick" }, { Value = "2", Text = "Chris" } ]
// Value only or Id and Value are the same
List<string> colors = [ "red", "green", "blue" ];
List<SelectListItem> colorOptions = colors.Select(x => x.ToSelectListItem()); // [ { Value = "red", Text = "red" }, { Value = "green", Text = "green" }, { Value = "blue", Text = "blue" } ]
</details>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- CommonNetFuncs.Sql.Common (>= 3.6.1)
- CommonNetFuncs.Web.Common (>= 3.6.1)
- MemoryPack (>= 1.21.4)
- MessagePack (>= 3.1.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
3.6.1 | 130 | 7/14/2025 |
3.6.0 | 150 | 7/14/2025 |
3.5.3 | 133 | 7/10/2025 |
3.5.0 | 142 | 7/7/2025 |
3.4.23 | 134 | 6/26/2025 |
3.4.21 | 129 | 6/26/2025 |
3.4.20 | 132 | 6/25/2025 |
3.4.18 | 135 | 6/23/2025 |
3.4.13 | 234 | 6/13/2025 |
3.4.9 | 286 | 6/11/2025 |
3.4.8 | 279 | 6/11/2025 |
3.4.2 | 145 | 6/2/2025 |
3.4.1 | 96 | 5/30/2025 |
3.4.0 | 94 | 5/30/2025 |
3.3.14 | 147 | 5/21/2025 |
3.3.11 | 145 | 5/18/2025 |
3.3.10 | 244 | 5/13/2025 |
3.3.0 | 165 | 4/29/2025 |
3.2.22 | 228 | 3/12/2025 |
3.2.13 | 113 | 2/13/2025 |
3.2.9 | 117 | 2/4/2025 |
3.2.8 | 112 | 1/31/2025 |
3.2.5 | 93 | 1/27/2025 |
3.2.3 | 134 | 1/17/2025 |
3.2.1 | 111 | 1/7/2025 |
3.2.0 | 107 | 12/19/2024 |
3.1.2 | 158 | 12/13/2024 |
3.1.1 | 118 | 12/10/2024 |
3.1.0 | 139 | 12/6/2024 |
3.0.0 | 125 | 12/3/2024 |
2.1.3 | 116 | 12/3/2024 |
2.1.0 | 118 | 12/2/2024 |
2.0.5 | 120 | 11/26/2024 |
2.0.2 | 120 | 11/18/2024 |
2.0.1 | 110 | 11/15/2024 |
2.0.0 | 109 | 11/14/2024 |
1.0.47 | 124 | 11/14/2024 |
1.0.42 | 156 | 11/12/2024 |
1.0.40 | 124 | 11/12/2024 |
1.0.37 | 122 | 11/4/2024 |
1.0.31 | 116 | 10/31/2024 |
1.0.28 | 132 | 10/25/2024 |
1.0.26 | 154 | 10/18/2024 |
1.0.25 | 82 | 10/17/2024 |
1.0.24 | 88 | 10/17/2024 |
1.0.18 | 127 | 10/11/2024 |
1.0.17 | 116 | 9/27/2024 |
1.0.16 | 112 | 9/27/2024 |
1.0.15 | 116 | 9/23/2024 |
1.0.13 | 125 | 9/18/2024 |
1.0.12 | 124 | 9/18/2024 |
1.0.11 | 110 | 9/18/2024 |
1.0.10 | 136 | 9/11/2024 |
1.0.9 | 116 | 9/11/2024 |
1.0.8 | 137 | 9/11/2024 |
1.0.7 | 130 | 9/11/2024 |
1.0.1 | 131 | 9/4/2024 |
1.0.0 | 112 | 9/2/2024 |