Code
·
137 lines
·
2595 bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
using Microsoft.AspNetCore.Mvc;
namespace NetproxySolution.Web.Controllers;
public class DefaultController : ControllerBase
{
[HttpPost("~/api/HelloWorld")]
public async Task<IActionResult> HelloWorld(string name)
{
await Task.Yield();
HttpContext.Session.SetString("name", name);
return Ok(new
{
Message = $"{name} says Hello, World!"
});
}
[HttpGet("~/api/NullContent")]
public async Task<IActionResult> NullContentAsync()
{
await Task.Yield();
return Ok(null);
}
[HttpGet("~/api/EmptyContent")]
public async Task<IActionResult> EmptyContent()
{
await Task.Yield();
return Ok();
}
public class ModelClass
{
public string? User { get; set; }
}
[HttpPost("~/api/SomePost")]
public async Task<IActionResult> SomePost(ModelClass Model)
{
await Task.Yield();
var message = $"yess {Model.User}";
return Ok(new
{
Message = message
});
}
[HttpPost("~/api/TestLongRunning")]
public async Task<IActionResult> TestLongRunning(int TimeOut)
{
await Task.Delay(TimeOut);
return Ok(new
{
Message = $"This took {TimeOut}mS"
});
}
/// <summary>
/// Uploads have default a maximum of 30MByte presenting upload example of 2.5GB
///
/// For IIS Limit maxAllowedContentLength in Web.config (in the root of the app, not in wwwroot content folder!)
///
/// </summary>
/// <param name="formFile"></param>
/// <returns></returns>
[HttpPost("~/api/Upload")]
[RequestSizeLimit(2_500_000_000)]
[RequestFormLimits(MultipartBodyLengthLimit = 2_500_000_000)]
public async Task<IActionResult> Upload(IFormFile file, string Form1)
{
if (file == null || file.Length <= 0)
return NotFound("File not uploaded");
var Length = file.Length;
using var ms = new MemoryStream(); // FileStream for production
await file.CopyToAsync(ms);
return Ok(new
{
Length,
Form1
});
}
[HttpGet("~/api/NotFound")]
public async Task<IActionResult> CanYouFindIt()
{
await Task.Yield();
return NotFound();
}
[HttpGet("~/api/ReturnServerError")]
public async Task<IActionResult> ReturnServerErrorAsync()
{
await Task.Yield();
try
{
var i = 0;
var j = 1 / i;
return Ok();
}
catch (Exception eee)
{
return StatusCode(500, new { eee.Message, eee.StackTrace } );
}
}
[HttpGet("~/api/MakeServerError")]
public async Task<IActionResult> MakeServerErrorAsync()
{
await Task.Yield();
var i = 0;
var j = 1 / i;
return Ok();
}
[HttpPost("~/app/gps/location")]
public IActionResult GpsLocation(double latitude, double longitude, string timestamp)
{
return Ok();
}
}