Here is program.cs:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllersWithViews();
var app = builder.Build();
app.UseStaticFiles();
app.UseRouting();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();
Top comments (2)
if you want to test it try adding a controller like this
`
public class Controller : Controller
{
public IActionResult Index()
{
List ConList = new Con().GetCons();
return View(ConList);
}
`
Sorry and for your adding model I would make it like this :
`
private static List ConList = new List();
`
and for some logic to loop through and display you'll probably want this
in your views
`
@foreach (var currentCon in Model)
{
@using (Html.BeginForm("Add", "Con", FormMethod.Post))
{
@html.LabelFor(m => m.ConName)
@html.EditorFor(m => m.ConName, new { htmlAttributes = new { placeholder = "ConName" } })
or the asp helpers instead :
`