I Have the simplest web page, a line of text. When I dotnet build & dotnet run, then launch the webpage, nothing is displayed despite the code being built fine. Any ideas?
My HTML code
@page
@model WebApp.Pages.ViewActors
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Web App</title>
</head>
<body>
<h1>@Model.Heading</h1>
</body>
</html>
My C# class
namespace WebApp.Pages
{
public class ViewActors : PageModel
{
public String Heading { get; set; }
public void onGet()
{
Heading = "James Bond Actors";
}
}
}
So Model.heading = "James Bond Actors"
But the page source only displays,
<html lang="en"><head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Web App</title>
</head>
<body>
<h1></h1>
</body></html>
With nothing displayed between
<h1></h1>
Any help would be appreciated.
I’ve tried basic text and that displays but not the model.heading & viewed similar questions but no help. Thanks
>Solution :
onGet() should be OnGet() with a capital O.