Mode:
Duration:
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
using Microsoft.AspNetCore.Mvc;
public class DemoController : Controller
{
public IActionResult ViewExample()
{
return View(); // ViewResult
}
public IActionResult JsonExample()
{
return Json(new { Name = "Alice", Age = 25 }); // JsonResult
}
public IActionResult ContentExample()
{
return Content("Hello World"); // ContentResult
}
public IActionResult RedirectExample()
{
return Redirect("https://example.com"); // RedirectResult
}
public IActionResult FileExample()
{
byte[] fileBytes = System.Text.Encoding.UTF8.GetBytes("Sample File Content");
return File(fileBytes, "text/plain", "sample.txt"); // FileResult
}
}Coding works best on desktop or with an external keyboard.