📘 Project Name: Student Record
✅ Purpose:
Allow users to:
● Add a student's name and course.
● View all students.
🔧 Steps to Create
Step 1: Create Project
● Open Visual Studio
● Select: [Link] Core Web App (Model-View-Controller)
● Name it: StudentRecord
● Click Create
Step 2: Create Model
📄 Models/[Link]
csharp
CopyEdit
namespace [Link]
{
public class Student
{
public int Id { get; set; }
public string Name { get; set; }
public string Course { get; set; }
}
}
Step 3: Create Controller
📄 Controllers/[Link]
csharp
CopyEdit
using [Link];
using [Link];
using [Link];
using [Link];
namespace [Link]
{
public class StudentController : Controller
{
static List<Student> students = new List<Student>();
public IActionResult Index()
{
return View(students);
}
public IActionResult Create()
{
return View();
}
[HttpPost]
public IActionResult Create(Student s)
{
[Link] = [Link] + 1;
[Link](s);
return RedirectToAction("Index");
}
}
}
Step 4: Create Views
📁 Views/Student/[Link]
html
CopyEdit
@model List<[Link]>
<h2>Student List</h2>
<a asp-action="Create">Add Student</a>
<table border="1">
<tr><th>ID</th><th>Name</th><th>Course</th></tr>
@foreach (var s in Model)
{
<tr>
<td>@[Link]</td>
<td>@[Link]</td>
<td>@[Link]</td>
</tr>
}
</table>
📁 Views/Student/[Link]
html
CopyEdit
@model [Link]
<h2>Add Student</h2>
<form asp-action="Create" method="post">
<label>Name</label>
<input asp-for="Name" /><br />
<label>Course</label>
<input asp-for="Course" /><br />
<button type="submit">Save</button>
</form>
▶️ How to Run:
● Set StudentController as start page in [Link] or navigate to
/Student
● Press Ctrl + F5
● Add and view students easily!