syneffort 2 years ago
parent ef66c15aad
commit 6589b90e70
  1. 15
      BlazorApp/AspNetCoreMVC/Controllers/HomeController.cs
  2. 5
      BlazorApp/AspNetCoreMVC/Models/Models.cs
  3. 29
      BlazorApp/AspNetCoreMVC/Views/Home/Test.cshtml
  4. 13
      BlazorApp/AspNetCoreMVC/Views/Home/Test.cshtml.cs

@ -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;
} }

@ -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; }
}
} }

@ -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>

@ -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()
{
}
}
}
Loading…
Cancel
Save