I am having an issue with my code where my OnGet()
method isn’t being called when the page loads. Now I may be wrong on how the OnGet()
method is supposed to work but I cannot seem to figured out at bare minimum a work around. Here is my Index.cshtml.cs file:
using System;
using System.Collections;
using System.Linq;
using System.Dynamic;
using Microsoft.AspNetCore.Mvc.Razor;
using SafetyApp.Services;
namespace SafetyApp.Pages
{
public class IndexModel : PageModel
{
private readonly SafetyService _safety;
public IndexModel(SafetyService safety)
{
_safety = safety;
}
public void OnGet()
{
var inspectionType = _safety.GetInspectionType();
}
}
}
As you can see I have a constructor for the safety class and I set a variable equal to the result of that method. Thank-you for any insight on this problem I am having.