Hello All,
I am using ASP .Net Core 3.1 Razor Pages (non-MVC) with Entity Framework Core.
Consider the following OnGet() Handler in an Index.cs file:
public IActionResult OnGet()
{
var webRootPath = _hostingEnvironment.WebRootPath;
var docsPath = Path.Combine(webRootPath, "documents");
var DocumentInformation = Directory.GetFiles(docsPath, "*.*", SearchOption.TopDirectoryOnly);
return Page();
}
This code returns an array of files in the wwwroot/documents directory.
This array is read into the local variable var DocumentInformation
My question:
Instead of using a local variable, I would like to create a model, that can not only be passed back to the .cshtml file, but can be used in other parts of my application.
I don't want the model to be used to create a database table.
I would appreciate any guidance on how to accomplish this.
Thanks in advance for your time....