It is not typical that you would try to run code directly from program.cs in a web application. Normally you would use a pattern like MVC (Model, View, Controller) to handle information transfer. In the case of MVC your view would send information back to your controller. Then your controller could use that information however you would like.
Heres a link to microsofts documentation on MVC in .net core.
https://docs.microsoft.com/en-us/aspnet/core/mvc/overview?view=aspnetcore-2.2
Also it will help to familiarize yourself with the http verbs like GET, POST, PUT, DELETE and how you can use them. You can use HTML form elements to perform most of these actions. Heres a Link to a form Example.
https://www.w3schools.com/html/html_forms.asp
Another way to handle sending the data back your controller would be using JavaScript. It is a bit more complicated than using a form but can be much more flexible. Heres a link to the javascript fetch API.
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
and heres a quick example -
This is a simple form that links to my customer controller then activates the Location or date method.
<form action="Customer/Location">
<input type="submit" class="SelectByLocation SelectBy" value="Location" />
</form>
<div id="CustApptTypeSelectScreen" class="SelectApptType">
<form action="Customer/Location">
<input type="submit" class="SelectByLocation SelectBy" value="Location" />
</form>
<form action="Customer/Date">
<input type="submit" class="SelectByDate SelectBy" value="Date" />
</form>
</div>
This is the controller its self with the Location() function. When you click Location Button it will go to that function and run it.
public class CustomerController : Controller
{
public IActionResult Index()
{
return View();
}
public IActionResult Date()
{
return View("Date");
}
public IActionResult Location()
{
doSomethingFunction();
return View("Location");
}
}
I hope something here helps.
-Good Luck.