This commit is contained in:
2023-08-29 16:01:05 +09:00
parent ef66c15aad
commit 6589b90e70
4 changed files with 61 additions and 1 deletions

View File

@@ -25,7 +25,20 @@ namespace AspNetCoreMVC.Controllers
return View(); return View();
} }
public IActionResult Test(int id, [FromHeader] string value) public IActionResult Test()
{
TestViewModel viewModel = new TestViewModel()
{
Names = new List<string>()
{
"One", "Two", "Three"
}
};
return View(viewModel);
}
public IActionResult Test1(int id, [FromHeader] string value)
{ {
return null; return null;
} }

View File

@@ -10,4 +10,9 @@ namespace AspNetCoreMVC.Models
[StringLength(20)] [StringLength(20)]
public string Name { get; set; } public string Name { get; set; }
} }
public class TestViewModel
{
public List<string> Names { get; set; }
}
} }

View File

@@ -0,0 +1,29 @@
@model TestViewModel
@{
}
@* Render section *@
@section Scripts {
<h1 style="color:red">I am scripts section!</h1>
}
<h1>Hello Razor Template</h1>
<h2>@DateTime.Now This value come from C#</h2>
<h3>@(1 + 1)</h3>
@if (Model.Names.Count < 5)
{
<h1>a little bit of data</h1>
}
else
{
<h1>a lot of data</h1>
}
<ul>
@for (int i = 0; i < Model.Names.Count; i++)
{
<li>@Model.Names[i]</li>
}
</ul>

View File

@@ -0,0 +1,13 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Timers;
namespace AspNetCoreMVC.Views.Home
{
public class TestModel : PageModel
{
public void OnGet()
{
}
}
}