netproxy 2.0.5
See the version list below for details.
dotnet add package netproxy --version 2.0.5
NuGet\Install-Package netproxy -Version 2.0.5
<PackageReference Include="netproxy" Version="2.0.5" />
paket add netproxy --version 2.0.5
#r "nuget: netproxy, 2.0.5"
// Install netproxy as a Cake Addin #addin nuget:?package=netproxy&version=2.0.5 // Install netproxy as a Cake Tool #tool nuget:?package=netproxy&version=2.0.5
netproxy 2.0
Nuget package https://www.nuget.org/packages/netproxy/
This package depends on the nuget package https://www.nuget.org/packages/Mvc.ModelBinding.MultiParameter/
The netproxy package consists of some small javascript macros and javascript methods to make json calls to .net core controllers. There are no dependencies and is fully modern DOM compatible.
Synchronous calls:
netproxy("./api/helloworld", null, function ()
{
alert(this.Message);
});
netproxy("./api/post",
{
model:
{
user: 'alphons'
}
}, function()
{
alert(this.Message);
});
Asynchronous calls:
result = await netproxyasync("./api/helloworld", null);
alert(result.Message);
result = await netproxyasync("./api/post",
{
model:
{
user: 'alphons'
}
});
alert(result.Message);
Uploading file:
var formData = new FormData();
formData.append("file", file, file.name);
formData.append("Form1", "Value1"); // some extra Form data
netproxy("/api/upload", formData, function ()
{
alert("Result:" + this.Message);
}, window.NetProxyErrorHandler, ProgressHandler);
var result = await netproxyasync("/api/upload", formData, window.NetProxyErrorHandler, ProgressHandler);
alert("Result:" + result.Message);
A .net core controller handling the upload request must have attributes set for huge uploads.
[HttpPost]
[Route("~/api/upload")]
[RequestSizeLimit(2_500_000_000)]
[RequestFormLimits(MultipartBodyLengthLimit = 2_500_000_000)]
public async Task<IActionResult> Upload(IFormFile file, string Form1)
{
if (file.Length > 0)
{
using var ms = new MemoryStream();
await file.CopyToAsync(ms); // some dummy operation
}
return Ok(new
{
file.Length,
Form1
});
}
For uploading big huge files and hosting inside IIS add requestLimits changes to web.config file are necessary.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<remove name="aspNetCore" />
<add name="aspNetCore" path="*" verb="*"
modules="AspNetCoreModuleV2"
resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%"
arguments="%LAUNCHER_ARGS%"
stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout"
hostingModel="InProcess" />
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2500000000" />
</requestFiltering>
</security>
</system.webServer>
</configuration>
The multiparameter model binding to MVC Core using nuget package Mvc.ModelBinding.MultiParameter is part of netproxy as of version 1.1.0 and later.
result = await netproxyasync("./api/SomeMethod/two?SomeParameter3=three&SomeParameter6=six",
{
"SomeParameter4": // Now the beast has a name
{
Name: "four",
"Users":
[
[{ Name: "User00", Alias: ['aliasa', 'aliasb', 'aliasc'] }, { Name: "User01" }],
[{ Name: "User10" }, { Name: "User11" }],
[{ Name: "User20" }, { Name: "User21" }]
]
},
"SomeParameter5": "five" // double binder
});
alert(result.SomeParameter4.Users[0][0].Alias[1]); // 'aliasb'
[HttpPost]
[Route("~/api/SomeMethod/{SomeParameter2}")]
public async Task<IActionResult> DemoMethod(
[FromCooky(Name = ".AspNetCore.Session")] string SomeParameter0,
[FromHeader(Name = "Referer")] string SomeParameter1,
[FromRoute] string SomeParameter2,
[FromQuery] string SomeParameter3,
[FromBody] ApiModel SomeParameter4,
[FromBody] string SomeParameter5,
[FromQuery]string SomeParameter6)
{
await Task.Yield();
return Ok(new
{
SomeParameter0,
SomeParameter1,
SomeParameter2,
SomeParameter3,
SomeParameter4,
SomeParameter5,
SomeParameter6
);
}
When parameters have unique names this can be simplified to:
[HttpPost]
[Route("~/api/SomeMethod2/{SomeParameter2}")]
public async Task<IActionResult> DemoMethod2(
string Referer,
string SomeParameter2,
string SomeParameter3,
ApiModel SomeParameter4,
string SomeParameter5,
string SomeParameter6)
{
await Task.Yield();
return Ok(new
{
Referer,
SomeParameter2,
SomeParameter3,
SomeParameter4,
SomeParameter5,
SomeParameter6
);
}
For more tests see the Mvc.ModelBinding.MultiParameter project on github.
Learn more about Target Frameworks and .NET Standard.
-
- Mvc.ModelBinding.MultiParameter (>= 1.1.8)
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 |
---|---|---|
8.0.1 | 70 | 11/25/2024 |
3.0.1 | 81 | 11/23/2024 |
3.0.0 | 79 | 11/23/2024 |
2.1.0 | 221 | 3/4/2024 |
2.0.5 | 270 | 1/23/2024 |
2.0.4 | 241 | 1/23/2024 |
2.0.3 | 188 | 1/23/2024 |
2.0.2 | 244 | 12/19/2023 |
2.0.1 | 224 | 11/25/2023 |
1.1.8 | 237 | 11/17/2023 |
1.1.4 | 579 | 5/9/2022 |
1.1.3 | 506 | 4/20/2022 |
1.1.2 | 490 | 4/19/2022 |
1.1.1 | 536 | 4/18/2022 |
1.1.0 | 530 | 4/18/2022 |
1.0.7 | 510 | 4/18/2022 |