I am a Razor newbie, just can't run sample copied from : https://docs.microsoft.com/en-us/aspnet/core/razor-pages/?view=aspnetcore-2.2&tabs=visual-studio
My index.cshtml:
@page
@model IndexModel
<h2>Separate page model</h2>
<p>
@Model.Message
</p>
My index.cshtml.cs
using Microsoft.AspNetCore.Mvc.RazorPages;
using System;
namespace aspnetcoreapp.Pages
{
public class IndexModel : PageModel
{
public string Message { get; private set; } = "PageModel in C#";
public void OnGet()
{
Message += $" Server time is { DateTime.Now }";
}
}
}
But when I browse this page I receive this error :
An error occurred during the compilation of a resource required to process this request. Please review the following specific error details and modify your source code appropriately. C:\temp\aspnetcoreapp\Pages\Index.cshtml
'IndexModel' does not contain a definition for 'Message' and no extension method 'Message' accepting a first argument of type 'IndexModel' could be found (are you missing a using directive or an assembly reference?) + @Model.Message