0% found this document useful (0 votes)
65 views56 pages

Lab Manual - DotNet (CS-406) May 2025

Uploaded by

Ansh Viswakarma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views56 pages

Lab Manual - DotNet (CS-406) May 2025

Uploaded by

Ansh Viswakarma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

GYAN GANGA INSTITUTE OF TECHNOLOGY AND SCIENCES,

JABALPUR

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

LAB MANUAL

Programming Practice (Dot Net)

(CS-406)

NAME:

ENROLLMENT NUMBER:

SESSION: 2024-25

Page 1 of 56
Subject Name: Programming Practices (b) (DotNet)
Subject Code: [CS-406]
Index
S. Experiment Date of Sign Remarks
No. Performance

1 Create Web Application as Login page


in [Link] using database connectivity.

2 Create a Registration Page on [Link]


to insert, update, delete and search a
record using Data controls.

3 Create a Windows Based Application


using .Net framework

4 Create a project on Console application


of Employee Management System.

5 Create a [Link] core application for


supporting multiple platform.

6 Create a Razor page web application


available in [Link] core templates.

7 Create a Quiz Application with [Link]


MVC in [Link] core

8 Create Web API (REST Service) in


[Link] core.

9 Create a Blazor Web App that support


both server side rendering and client
interactivity.
10 Create a project based on User Staff
Registration on [Link] and
Deployment on web server.

Page 2 of 56
Evaluation Sheet
Student Name :
Student Roll No.:
Subject Name :
Subject Code:
Practical
Record Execution & Record
Completion Result Viva Submission
(6 marks) (6 marks) (4 marks) (4 marks)
Complete Record Record
4 Total
Proper Output Answer
S. with correct 6 for all program 6 Correctly 4 submitted in
Name of Experiment syntax time out of
No Complete Record Proper Output Answer Record not 20
with improper 4 for some 4 Satisfactori 2 submitted in 2
syntax program ly time
Partially Complete Unable to Record Not
Record 2 Partial Output 2 Answer 0 Submitted 0
Output not
Incomplete Record 0 shown 0
Create Web Application as Login
1 page in [Link] using database
connectivity.
Create a Registration Page on
[Link] to insert, update, delete
2 and search a record using Data
controls.
Create a Windows Based
3 Application using .Net framework
Create a project on Console
4 application of Employee
Management System.
Create a [Link] core application
5 for supporting multiple platform.
Create a Razor page web
6 application available in [Link]
core templates.
Create a Quiz Application with
7 [Link] MVC in [Link] core

Create Web API (REST Service)


8 in [Link] core.
Create a Blazor Web App that
9 support both server side rendering
and client interactivity.
Create a project based on User
10 Staff Registration on [Link] and
Deployment on web server.

Grand Total
Marks out of 20

Signature of Subject Faculty

Page 3 of 56
Experiment-1

Create Web Application as Login page in [Link] using database connectivity.

[Link] Web Application for a Login Page using C# with SQL Server Database
Connectivity.

Features:

● Users can log in using their email and password.


● SQL Server database is used to verify credentials.
● Session management to keep track of logged-in users.
● Bootstrap for styling.

Steps to Set Up the Application


Create a SQL Database Table
Run the following SQL script in SQL Server:
CREATE DATABASE UserDB;
USE UserDB;
CREATE TABLE Users (
Id INT PRIMARY KEY IDENTITY(1,1),
Email NVARCHAR(100) UNIQUE NOT NULL,
Password NVARCHAR(255) NOT NULL
);
-- Insert a test user (password should be hashed in production)
INSERT INTO Users (Email, Password) VALUES ('test@[Link]', 'password123');

1. Create the [Link] Web Application


○ Open Visual Studio → Create [Link] Web Application → Select Web
Forms.

Code Implementation

1 [Link] (Database Connection String)

Add the following inside <configuration>:


<connectionStrings>
<add name="MyDB" connectionString="Data
Source=YOUR_SERVER_NAME;Initial Catalog=UserDB;Integrated Security=True"
providerName="[Link]"/>
</connectionStrings>

Page 4 of 56
Replace YOUR_SERVER_NAME with your actual SQL Server name.

2 [Link] (Frontend UI)


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="[Link]"
Inherits="[Link]" %>
<!DOCTYPE html>
<html> <head>
<title>Login</title>
<link rel="stylesheet"
href="[Link] />

</head>
<body>
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-4">
<h2 class="text-center">Login</h2>
<asp:Label ID="lblMessage" runat="server" ForeColor="Red"></asp:Label>
<div class="mb-3">
<label>Email</label>
<asp:TextBox ID="txtEmail" runat="server" CssClass="form-
control"></asp:TextBox>
</div>
<div class="mb-3">
<label>Password</label>
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password"
CssClass="form-control"></asp:TextBox>
</div>
<asp:Button ID="btnLogin" runat="server" Text="Login" CssClass="btn btn-
primary w-100" OnClick="btnLogin_Click" />
</div>
</div>
</div>
</body>
</html>

3 [Link] (C# Code-Behind)


using System;
using [Link];
using [Link];

public partial class Login : [Link]


{
protected void Page_Load(object sender, EventArgs e)
{
Page 5 of 56
[Link] = "";
}
protected void btnLogin_Click(object sender, EventArgs e)
{
string email = [Link]();
string password = [Link]();
string connString =
[Link]["MyDB"].ConnectionString;
using (SqlConnection conn = new SqlConnection(connString))
{
string query = "SELECT COUNT(*) FROM Users WHERE Email=@Email
AND Password=@Password";
SqlCommand cmd = new SqlCommand(query, conn);
[Link]("@Email", email);
[Link]("@Password", password);
[Link]();
int count = (int)[Link]();
[Link]();
if (count > 0)
{
Session["UserEmail"] = email;
[Link]("[Link]");
}
else
{
[Link] = "Invalid email or password!";
}
}
}
}

4 [Link] (Protected Page)


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="[Link]"
Inherits="[Link]" %>
<!DOCTYPE html>
<html>
<head>
<title>Dashboard</title>
<link rel="stylesheet"
href="[Link] />
</head>
<body>
<div class="container mt-5">
<h2>Welcome, <asp:Label ID="lblUser" runat="server"></asp:Label></h2>
<asp:Button ID="btnLogout" runat="server" Text="Logout" CssClass="btn btn-
danger" OnClick="btnLogout_Click" />
</div>
</body>
Page 6 of 56
</html>

5 [Link]
using System;
public partial class Dashboard : [Link]
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["UserEmail"] == null)
{
[Link]("[Link]");
}
else
{
[Link] = Session["UserEmail"].ToString();
}
}
protected void btnLogout_Click(object sender, EventArgs e)
{
[Link]();
[Link]("[Link]");
}
}

How It Works

1. User enters email and password in [Link].


2. C# code verifies credentials against the database.
3. If valid, Session is created, and the user is redirected to [Link].
4. Session check in [Link] ensures unauthorized users are redirected
back to the login page.
5. Logout button clears session and redirects back to [Link].

Page 7 of 56
Experiment- 02

Create a Registration Page on [Link] to insert, update, delete and search a record using
Data controls.

[Link] Web Application with a Registration Page that allows users to insert, update,
delete, and search records in a SQL Server database using C#.

Features

✅ Insert a new user


✅ Update existing user details
✅ Delete a user record
✅ Search for a user
✅ [Link] Web Forms + C# + SQL Server

1. Create SQL Database Table

Run this SQL script to create the Users table in SQL Server:

CREATE DATABASE UserDB;


USE UserDB;

CREATE TABLE Users (


Id INT PRIMARY KEY IDENTITY(1,1),
FullName NVARCHAR(100) NOT NULL,
Email NVARCHAR(100) UNIQUE NOT NULL,
Password NVARCHAR(255) NOT NULL,
Phone NVARCHAR(15) NULL
);

2. Add Database Connection in [Link]

Add this inside the <configuration> section:

<connectionStrings>
<add name="MyDB" connectionString="Data
Source=YOUR_SERVER_NAME;Initial Catalog=UserDB;Integrated Security=True"
providerName="[Link]"/>
</connectionStrings>

Page 8 of 56
Replace YOUR_SERVER_NAME with your actual SQL Server name.

3. Create [Link] (User Interface)


<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="[Link]" Inherits="[Link]" %>

<!DOCTYPE html>
<html>
<head>
<title>Registration Page</title>
<link rel="stylesheet"
href="[Link] />
</head>
<body>
<div class="container mt-5">
<h2 class="text-center">User Registration</h2>
<asp:Label ID="lblMessage" runat="server" ForeColor="Red"></asp:Label>

<div class="mb-3">
<label>Full Name</label>
<asp:TextBox ID="txtFullName" runat="server" CssClass="form-
control"></asp:TextBox>
</div>
<div class="mb-3">
<label>Email</label>
<asp:TextBox ID="txtEmail" runat="server" CssClass="form-
control"></asp:TextBox>
</div>
<div class="mb-3">
<label>Password</label>
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password"
CssClass="form-control"></asp:TextBox>
</div>
<div class="mb-3">
<label>Phone</label>
<asp:TextBox ID="txtPhone" runat="server" CssClass="form-
control"></asp:TextBox>
</div>

<asp:Button ID="btnSave" runat="server" Text="Save" CssClass="btn btn-primary"


OnClick="btnSave_Click" />
<asp:Button ID="btnUpdate" runat="server" Text="Update" CssClass="btn btn-
warning" OnClick="btnUpdate_Click" />
<asp:Button ID="btnDelete" runat="server" Text="Delete" CssClass="btn btn-
danger" OnClick="btnDelete_Click" />

Page 9 of 56
<asp:Button ID="btnSearch" runat="server" Text="Search" CssClass="btn btn-
secondary" OnClick="btnSearch_Click" />

<div class="mt-3">
<h4>Users List</h4>
<asp:GridView ID="GridView1" runat="server" CssClass="table table-bordered"
AutoGenerateColumns="False" DataKeyNames="Id">
<Columns>
<asp:BoundField DataField="Id" HeaderText="ID" />
<asp:BoundField DataField="FullName" HeaderText="Full Name" />
<asp:BoundField DataField="Email" HeaderText="Email" />
<asp:BoundField DataField="Phone" HeaderText="Phone" />
</Columns>
</asp:GridView>
</div>
</div>
</body>
</html>

4. Backend Code ([Link])


using System;
using [Link];
using [Link];
using [Link];

public partial class Registration : [Link]


{
string connString =
[Link]["MyDB"].ConnectionString;

protected void Page_Load(object sender, EventArgs e)


{
if (!IsPostBack)
{
LoadUsers();
}
}

// INSERT RECORD
protected void btnSave_Click(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(connString))
{
string query = "INSERT INTO Users (FullName, Email, Password, Phone)
VALUES (@FullName, @Email, @Password, @Phone)";
Page 10 of 56
SqlCommand cmd = new SqlCommand(query, conn);
[Link]("@FullName", [Link]);
[Link]("@Email", [Link]);
[Link]("@Password", [Link]);
[Link]("@Phone", [Link]);

[Link]();
[Link]();
[Link]();

[Link] = "User added successfully!";


LoadUsers();
}
}

// UPDATE RECORD
protected void btnUpdate_Click(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(connString))
{
string query = "UPDATE Users SET FullName=@FullName,
Password=@Password, Phone=@Phone WHERE Email=@Email";
SqlCommand cmd = new SqlCommand(query, conn);
[Link]("@FullName", [Link]);
[Link]("@Email", [Link]);
[Link]("@Password", [Link]);
[Link]("@Phone", [Link]);

[Link]();
int rowsAffected = [Link]();
[Link]();

[Link] = rowsAffected > 0 ? "User updated successfully!" : "User not


found!";
LoadUsers();
}
}

// DELETE RECORD
protected void btnDelete_Click(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(connString))
{
string query = "DELETE FROM Users WHERE Email=@Email";
SqlCommand cmd = new SqlCommand(query, conn);
[Link]("@Email", [Link]);

[Link]();
Page 11 of 56
int rowsAffected = [Link]();
[Link]();

[Link] = rowsAffected > 0 ? "User deleted successfully!" : "User not


found!";
LoadUsers();
}
}

// SEARCH RECORD
protected void btnSearch_Click(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(connString))
{
string query = "SELECT * FROM Users WHERE Email=@Email";
SqlCommand cmd = new SqlCommand(query, conn);
[Link]("@Email", [Link]);

[Link]();
SqlDataReader reader = [Link]();
if ([Link]())
{
[Link] = reader["FullName"].ToString();
[Link] = reader["Password"].ToString();
[Link] = reader["Phone"].ToString();
[Link] = "User found!";
}
else
{
[Link] = "User not found!";
}
[Link]();
}
}

// LOAD USERS IN GRIDVIEW


private void LoadUsers()
{
using (SqlConnection conn = new SqlConnection(connString))
{
string query = "SELECT Id, FullName, Email, Phone FROM Users";
SqlDataAdapter da = new SqlDataAdapter(query, conn);
DataTable dt = new DataTable();
[Link](dt);
[Link] = dt;
[Link]();
}
}}
Page 12 of 56
How It Works

✅ Insert a new user


✅ Update user details using email
✅ Delete a user by email
✅ Search for a user by email
✅ Display all users in a GridView

Page 13 of 56
Experiment- 03

Create a Windows Based Application using .Net framework

Windows Forms Application in C# (.NET Framework) that performs CRUD


operations (Insert, Update, Delete, and Search) using SQL Server.

Prerequisites

● Visual Studio (2019 or later)


● .NET Framework (Windows Forms App)
● SQL Server (LocalDB or Full SQL Server)

1. Create SQL Database and Table

Run this SQL script to create a database and table:


CREATE DATABASE UserDB;
USE UserDB;
CREATE TABLE Users (
Id INT PRIMARY KEY IDENTITY(1,1),
FullName NVARCHAR(100) NOT NULL,
Email NVARCHAR(100) UNIQUE NOT NULL,
Phone NVARCHAR(15) NULL
);

2. Create a Windows Forms Application

1. Open Visual Studio → Create a new project.


2. Select Windows Forms App (.NET Framework).
3. Choose C# and Click Next.
4. Name the project WinFormsCRUD and Click Create.

3. Add Database Connection ([Link])


Open [Link] and add:
<configuration>
<connectionStrings>

Page 14 of 56
<add name="MyDB" connectionString="Data
Source=YOUR_SERVER_NAME;Initial Catalog=UserDB;Integrated Security=True"
providerName="[Link]"/>
</connectionStrings>
</configuration>
Replace YOUR_SERVER_NAME with your actual SQL Server instance name.

4. Design the Windows Form ([Link])


1. Open [Link] in Design View.
2. Drag and drop the following controls from the Toolbox:
○ Labels: lblFullName, lblEmail, lblPhone
○ TextBoxes: txtFullName, txtEmail, txtPhone
○ Buttons: btnInsert, btnUpdate, btnDelete, btnSearch
○ DataGridView: dataGridViewUsers
3. Adjust layout and rename controls accordingly.

5. Code for [Link]


using System;
using [Link];
using [Link];
using [Link];
using [Link];

namespace WinFormsCRUD
{
public partial class Form1 : Form
{
string connString =
[Link]["MyDB"].ConnectionString;
public Form1()
{
InitializeComponent();
LoadUsers();
}
// Insert Record
private void btnInsert_Click(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(connString))
{
string query = "INSERT INTO Users (FullName, Email, Phone) VALUES
(@FullName, @Email, @Phone)";
SqlCommand cmd = new SqlCommand(query, conn);
Page 15 of 56
[Link]("@FullName", [Link]);
[Link]("@Email", [Link]);
[Link]("@Phone", [Link]);
[Link]();
[Link]();
[Link]();
[Link]("User added successfully!");
LoadUsers();
}
}
// Update Record
private void btnUpdate_Click(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(connString))
{
string query = "UPDATE Users SET FullName=@FullName, Phone=@Phone
WHERE Email=@Email";
SqlCommand cmd = new SqlCommand(query, conn);
[Link]("@FullName", [Link]);
[Link]("@Email", [Link]);
[Link]("@Phone", [Link]);
[Link]();
int rowsAffected = [Link]();
[Link]();
[Link](rowsAffected > 0 ? "User updated successfully!" : "User
not found!");
LoadUsers();
}
}
// Delete Record
private void btnDelete_Click(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(connString))
{
string query = "DELETE FROM Users WHERE Email=@Email";
SqlCommand cmd = new SqlCommand(query, conn);
[Link]("@Email", [Link]);
[Link]();
int rowsAffected = [Link]();
[Link]();
[Link](rowsAffected > 0 ? "User deleted successfully!" : "User not
found!");
Page 16 of 56
LoadUsers();
}
}
// Search Record
private void btnSearch_Click(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(connString))
{
string query = "SELECT * FROM Users WHERE Email=@Email";
SqlCommand cmd = new SqlCommand(query, conn);
[Link]("@Email", [Link]);
[Link]();
SqlDataReader reader = [Link]();
if ([Link]())
{
[Link] = reader["FullName"].ToString();
[Link] = reader["Phone"].ToString();
[Link]("User found!");
}
else
{
[Link]("User not found!");
}
[Link]();
}
}
// Load Users into DataGridView
private void LoadUsers()
{
using (SqlConnection conn = new SqlConnection(connString))
{
string query = "SELECT Id, FullName, Email, Phone FROM Users";
SqlDataAdapter da = new SqlDataAdapter(query, conn);
DataTable dt = new DataTable();
[Link](dt);
[Link] = dt;
}
}
}
}

Page 17 of 56
6. Run the Application
1. Start the application (Press F5).
2. Enter user details → Click Insert to add.
3. Enter email → Click Search to find a user.
4. Modify details → Click Update.
5. Delete a user by entering email and clicking Delete.

Features Implemented
✔ Insert new users
✔ Update user details
✔ Delete user records
✔ Search users by email
✔ Display all users in DataGridView

Page 18 of 56
Experiment- 04

Create a project on Console application of Employee Management System.

Console-Based Employee Management System using C# (.NET Framework/.NET


Core).

Features

✅ Add Employee
✅ Update Employee Details
✅ Delete Employee
✅ Search Employee
✅ Display All Employees

This project uses C# and a SQL Server database for storing employee records.

1. Create SQL Database and Table

Run this SQL script to create a database and table:


CREATE DATABASE EmployeeDB;
USE EmployeeDB;

CREATE TABLE Employees (


Id INT PRIMARY KEY IDENTITY(1,1),
Name NVARCHAR(100) NOT NULL,
Age INT NOT NULL,
Department NVARCHAR (50) NOT NULL,
Salary DECIMAL (10,2) NOT NULL
);

2. Create a New Console Application

1. Open Visual Studio


2. Create a new Console App (.NET Framework or .NET Core)
3. Install [Link] for database connectivity

Page 19 of 56
3. Add Database Connection

Inside [Link], add the database connection string:

<configuration>
<connectionStrings>
<add name="MyDB" connectionString="Data
Source=YOUR_SERVER_NAME;Initial Catalog=EmployeeDB;Integrated
Security=True" providerName="[Link]"/>
</connectionStrings>
</configuration>

Replace YOUR_SERVER_NAME with your actual SQL Server name.

4. Implement Employee Management System ([Link])


using System;
using [Link];
using [Link];
using [Link];

class Program
{
static string connString =
[Link]["MyDB"].ConnectionString;

static void Main()


{
while (true)
{
[Link]("\n--- Employee Management System ---");
[Link]("1. Add Employee");
[Link]("2. Update Employee");
[Link]("3. Delete Employee");
[Link]("4. Search Employee");
[Link]("5. Display All Employees");
[Link]("6. Exit");
[Link]("Choose an option: ");

switch ([Link]())

Page 20 of 56
{
case "1":
AddEmployee();
break;
case "2":
UpdateEmployee();
break;
case "3":
DeleteEmployee();
break;
case "4":
SearchEmployee();
break;
case "5":
DisplayEmployees();
break;
case "6":
return;
default:
[Link]("Invalid choice. Try again.");
break;
}
}
}

static void AddEmployee()


{
[Link]("\nEnter Name: ");
string name = [Link]();
[Link]("Enter Age: ");
int age = [Link]([Link]());
[Link]("Enter Department: ");
string department = [Link]();
[Link]("Enter Salary: ");
decimal salary = [Link]([Link]());

using (SqlConnection conn = new SqlConnection(connString))


{
string query = "INSERT INTO Employees (Name, Age, Department, Salary)
VALUES (@Name, @Age, @Department, @Salary)";
SqlCommand cmd = new SqlCommand(query, conn);
[Link]("@Name", name);
Page 21 of 56
[Link]("@Age", age);
[Link]("@Department", department);
[Link]("@Salary", salary);

[Link]();
[Link]();
[Link]();

[Link]("Employee added successfully!");


}
}

static void UpdateEmployee()


{
[Link]("\nEnter Employee ID to Update: ");
int id = [Link]([Link]());

[Link]("Enter New Name: ");


string name = [Link]();
[Link]("Enter New Age: ");
int age = [Link]([Link]());
[Link]("Enter New Department: ");
string department = [Link]();
[Link]("Enter New Salary: ");
decimal salary = [Link]([Link]());

using (SqlConnection conn = new SqlConnection(connString))


{
string query = "UPDATE Employees SET Name=@Name, Age=@Age,
Department=@Department, Salary=@Salary WHERE Id=@Id";
SqlCommand cmd = new SqlCommand(query, conn);
[Link]("@Id", id);
[Link]("@Name", name);
[Link]("@Age", age);
[Link]("@Department", department);
[Link]("@Salary", salary);

[Link]();
int rowsAffected = [Link]();
[Link]();

Page 22 of 56
[Link](rowsAffected > 0 ? "Employee updated successfully!" :
"Employee not found.");
}
}

static void DeleteEmployee()


{
[Link]("\nEnter Employee ID to Delete: ");
int id = [Link]([Link]());

using (SqlConnection conn = new SqlConnection(connString))


{
string query = "DELETE FROM Employees WHERE Id=@Id";
SqlCommand cmd = new SqlCommand(query, conn);
[Link]("@Id", id);

[Link]();
int rowsAffected = [Link]();
[Link]();

[Link](rowsAffected > 0 ? "Employee deleted successfully!" :


"Employee not found.");
}
}
static void SearchEmployee()
{
[Link]("\nEnter Employee ID to Search: ");
int id = [Link]([Link]());

using (SqlConnection conn = new SqlConnection(connString))


{
string query = "SELECT * FROM Employees WHERE Id=@Id";
SqlCommand cmd = new SqlCommand(query, conn);
[Link]("@Id", id);

[Link]();
SqlDataReader reader = [Link]();
if ([Link]())
{
[Link]("\n--- Employee Details ---");
[Link]($"ID: {reader["Id"]}");
[Link]($"Name: {reader["Name"]}");
Page 23 of 56
[Link]($"Age: {reader["Age"]}");
[Link]($"Department: {reader["Department"]}");
[Link]($"Salary: {reader["Salary"]}");
}
else
{
[Link]("Employee not found.");
}
[Link]();
}
}
static void DisplayEmployees()
{
using (SqlConnection conn = new SqlConnection(connString))
{
string query = "SELECT * FROM Employees";
SqlDataAdapter da = new SqlDataAdapter(query, conn);
DataTable dt = new DataTable();
[Link](dt);

[Link]("\n--- All Employees ---");


foreach (DataRow row in [Link])
{
[Link]($"ID: {row["Id"]}, Name: {row["Name"]}, Age:
{row["Age"]}, Department: {row["Department"]}, Salary: {row["Salary"]}");
}
}
}
}

5. Running the Console Application

1. Start the application (F5 in Visual Studio).


2. Choose an option from the menu:
○ Add Employee (Enter details).
○ Update Employee (Modify existing record).
○ Delete Employee (Remove an employee by ID).
○ Search Employee (Find details by ID).
○ Display All Employees (List all employees).
3. Perform CRUD operations as needed.

Page 24 of 56
Features Implemented

✔ Add Employee to Database


✔ Update Employee details
✔ Delete Employee record
✔ Search Employee by ID
✔ Display All Employees

Page 25 of 56
Experiment- 05

Create a [Link] core application for supporting multiple platform.

cross-platform [Link] Core Web Application using C# and Entity Framework


Core for database operations.

Features

✅ User Registration & Login


✅ Cross-Platform Support (Windows, Linux, macOS)
✅ CRUD Operations (Insert, Update, Delete, Read)
✅ Entity Framework Core for Database
✅ Razor Pages or MVC Architecture

Prerequisites

1. Install .NET Core SDK


○ Download from Microsoft .NET
2. Install Visual Studio Code or Visual Studio
○ VS Code + C# Extension
○ OR Visual Studio 2022+
3. Install SQL Server (or use SQLite/PostgreSQL for cross-platform support)

1. Create [Link] Core Web Application

Open a terminal and run:


dotnet new webapp -n MultiPlatformApp
cd MultiPlatformApp
dotnet run

● Open [Link] in your browser.

Page 26 of 56
2. Install Dependencies

Run the following command to install Entity Framework Core:


sh
dotnet add package [Link]
dotnet add package [Link]

3. Configure Database (Entity Framework Core)

Modify [Link]:
"ConnectionStrings": {
"DefaultConnection":
"Server=YOUR_SERVER_NAME;Database=MultiPlatformDB;Trusted_Connection=Tr
ue;"
}

For SQLite (Linux/macOS support), use:


"ConnectionStrings": {
"DefaultConnection": "Data Source=[Link]"
}

4. Create Models

Create a file Models/[Link]:


using [Link];

public class User


{
[Key]
public int Id { get; set; }
[Required]
public string Name { get; set; }
[Required, EmailAddress]
public string Email { get; set; }
[Required]
public string Password { get; set; }
}

Page 27 of 56
5. Create Database Context

Create a file Data/[Link]:


using [Link];
public class ApplicationDbContext : DbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) :
base(options) { }
public DbSet<User> Users { get; set; }
}

Modify [Link] to include database services:


using [Link];

var builder = [Link](args);


// Add database connection
[Link]<ApplicationDbContext>(options =>

[Link]([Link]("DefaultConnection"))
);
[Link]();
var app = [Link]();
[Link]();
[Link]();
[Link]();

6. Generate Database with Migrations

Run the following commands: sh


dotnet ef migrations add InitialCreate
dotnet ef database update

7. Create User CRUD Operations

Create a new Razor Page for user management:


dotnet new razorpage -n Users

Page 28 of 56
Edit Pages/Users/[Link]:
using [Link];
using [Link];
using [Link];
using [Link];
public class IndexModel : PageModel
{
private readonly ApplicationDbContext _context;
public IndexModel(ApplicationDbContext context)
{
_context = context;
}
public IList<User> Users { get; set; }
public async Task OnGetAsync()
{
Users = await _context.[Link]();
}
}

Edit Pages/Users/[Link]:
@page
@model [Link]
<h2>Users List</h2>
<table>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
</tr>
@foreach (var user in [Link])
{
<tr>
<td>@[Link]</td>
<td>@[Link]</td>
<td>@[Link]</td>
</tr>
}
</table>

Page 29 of 56
8. Running the Application

Run:sh dotnet run

Open [Link] to see the User List.

Cross-Platform Support

✅ Works on:

● Windows (SQL Server, SQLite)


● Linux (PostgreSQL, SQLite)
● macOS (SQLite, PostgreSQL)

Features Implemented

✔ [Link] Core Web App


✔ Cross-Platform Database Support
✔ CRUD Operations (Users)
✔ Entity Framework Core (EF Core)
✔ Razor Pages for UI

Page 30 of 56
Experiment- 06

Create a Razor page web application available in [Link] core templates.

Creating a Razor Pages Web Application in [Link] Core

This guide will walk you through building an [Link] Core Razor Pages Web
Application using C# and Entity Framework Core (EF Core) for database operations.

Features

✅ Modern Web UI with Razor Pages


✅ Entity Framework Core for Database Management
✅ CRUD Operations (Insert, Update, Delete, Read)
✅ Bootstrap for UI Styling
✅ Cross-Platform Support (Windows, Linux, macOS)

Prerequisites

1. Install .NET SDK from Microsoft .NET


2. Install Visual Studio 2022 (or Visual Studio Code with C# extension)
3. Install SQL Server (or use SQLite/PostgreSQL for cross-platform support)

1. Create a New [Link] Core Razor Pages App

Run the following command in a terminal: sh


dotnet new razor -n RazorApp
cd RazorApp
dotnet run

Open [Link] in your browser to see the default app.

2. Install Entity Framework Core

Run the following command:sh


dotnet add package [Link]
dotnet add package [Link]
Page 31 of 56
dotnet add package [Link]

3. Configure Database Connection

Modify [Link]:
"ConnectionStrings": {
"DefaultConnection":
"Server=YOUR_SERVER_NAME;Database=RazorAppDB;Trusted_Connection=True;
MultipleActiveResultSets=true"
}

For SQLite (Cross-platform Support):


"ConnectionStrings": {
"DefaultConnection": "Data Source=[Link]"
}

4. Create Database Model

Create a new folder Models and add a file [Link]:


using [Link];
public class Employee
{
[Key]
public int Id { get; set; }
[Required]
public string Name { get; set; }
[Required]
public string Position { get; set; }
[Required, DataType([Link])]
public decimal Salary { get; set; }
}

5. Create Database Context

Create a new file Data/[Link]:


using [Link];
public class ApplicationDbContext : DbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) :
base(options) { }

public DbSet<Employee> Employees { get; set; }


}

Modify [Link]:
Page 32 of 56
using [Link];
var builder = [Link](args);
// Add Database Context
[Link]<ApplicationDbContext>(options =>

[Link]([Link]("DefaultConnection"))
);

[Link]();
var app = [Link]();
[Link]();
[Link]();
[Link]();
[Link]();

6. Generate Database using Migrations

Run the following commands: sh


dotnet ef migrations add InitialCreate
dotnet ef database update

7. Create Razor Pages for Employee Management


dotnet new page -n Employees

Modify Pages/Employees/[Link]:
using [Link];
using [Link];
using [Link];
using [Link];
public class IndexModel : PageModel
{
private readonly ApplicationDbContext _context;

public IndexModel(ApplicationDbContext context)


{
_context = context;
}
public IList<Employee> Employees { get; set; }

public async Task OnGetAsync()


{
Employees = await _context.[Link]();
}
}

Modify Pages/Employees/[Link]:
Page 33 of 56
@page
@model [Link]
@{
ViewData["Title"] = "Employees";
}
<h2>Employee List</h2>
<a asp-page="Create" class="btn btn-primary">Add Employee</a>
<table class="table">
<tr>
<th>ID</th>
<th>Name</th>
<th>Position</th>
<th>Salary</th>
<th>Actions</th>
</tr>
@foreach (var employee in [Link])
{
<tr>
<td>@[Link]</td>
<td>@[Link]</td>
<td>@[Link]</td>
<td>@[Link]</td>
<td>
<a asp-page="Edit" asp-route-id="@[Link]" class="btn btn-
warning">Edit</a>
<a asp-page="Delete" asp-route-id="@[Link]" class="btn btn-
danger">Delete</a>
</td>
</tr>
}
</table>

8. Add Create, Edit, and Delete Pages


dotnet new page -n Create
dotnet new page -n Edit
dotnet new page -n Delete

Modify Pages/Employees/[Link]:
using [Link];
using [Link];
using [Link];
public class CreateModel : PageModel
{
private readonly ApplicationDbContext _context;

public CreateModel(ApplicationDbContext context)


{
Page 34 of 56
_context = context;
}
[BindProperty]
public Employee Employee { get; set; }
public async Task<IActionResult> OnPostAsync()
{
if (![Link])
return Page();

_context.[Link](Employee);
await _context.SaveChangesAsync();
return RedirectToPage("Index");
}
}

Modify Pages/Employees/[Link]:
@page
@model [Link]
<h2>Add Employee</h2>
<form method="post">
<label>Name:</label>
<input asp-for="[Link]" class="form-control" />

<label>Position:</label>
<input asp-for="[Link]" class="form-control" />
<label>Salary:</label>
<input asp-for="[Link]" class="form-control" />
<button type="submit" class="btn btn-success">Create</button>
</form>

9. Running the Application

Run:sh dotnet run

Open [Link] to manage employees.

Features Implemented

✔ [Link] Core Razor Pages


✔ Entity Framework Core Database
✔ CRUD Operations (Employees Management)
✔ Bootstrap for Styling
✔ Cross-Platform Support (Windows, Linux, macOS)

Page 35 of 56
Experiment-07

Create a Quiz Application with [Link] MVC in [Link] core .using c#

Creating a Quiz Application using [Link] Core MVC with C# involves setting up a
web application that allows users to take quizzes, view questions, submit answers, and
view results. Below is a basic walkthrough to get you started.

Tech Stack:

• [Link] Core MVC


• Entity Framework Core
• C#
• SQLite or SQL Server for database

Project Structure

QuizApp/

├── Controllers/
│ └── [Link]

├── Models/
│ ├── [Link]
│ ├── [Link]
│ └── [Link]

├── Views/
│ └── Quiz/
│ ├── [Link]
│ ├── [Link]
│ ├── [Link]
│ └── [Link]

├── Data/
Page 36 of 56
│ └── [Link]

├── [Link]
├── [Link]
└── [Link] (or inside [Link] in .NET 6+)

1. Create Models
[Link]
public class Quiz
{
public int Id { get; set; }
public string Title { get; set; }
public List<Question> Questions { get; set; }
}
[Link]
public class Question
{
public int Id { get; set; }
public string Text { get; set; }
public int QuizId { get; set; }
public Quiz Quiz { get; set; }
public List<Answer> Answers { get; set; }
}
[Link]
public class Answer
{
public int Id { get; set; }
public string Text { get; set; }
public bool IsCorrect { get; set; }
public int QuestionId { get; set; }
public Question Question { get; set; }
}

2. Set Up DbContext
[Link]
public class ApplicationDbContext : DbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) :
base(options) {}

Page 37 of 56
public DbSet<Quiz> Quizzes { get; set; }
public DbSet<Question> Questions { get; set; }
public DbSet<Answer> Answers { get; set; }
}
3. Configure Database in [Link] or [Link]
[Link]<ApplicationDbContext>(options =>
[Link]("Data Source=[Link]")); // or UseSqlServer
4. Create QuizController
[Link]
public class QuizController : Controller
{
private readonly ApplicationDbContext _context;

public QuizController(ApplicationDbContext context)


{
_context = context;
}
public IActionResult Index()
{
var quizzes = _context.[Link]();
return View(quizzes);
}
public IActionResult Start(int id)
{
var quiz = _context.Quizzes
.Include(q => [Link])
.ThenInclude(q => [Link])
.FirstOrDefault(q => [Link] == id);
return View(quiz);
}
[HttpPost]
public IActionResult Submit(Dictionary<int, int> answers)
{
int score = 0;
foreach (var entry in answers)
{
var answer = _context.[Link](a => [Link] == [Link]);
if (answer != null && [Link])
score++;
}

Page 38 of 56
[Link] = score;
[Link] = [Link];
return View("Result");
}
}
5. Create Views
Views/Quiz/[Link]
@model IEnumerable<Quiz>
<h2>Available Quizzes</h2>
@foreach (var quiz in Model)
{
<div>
<h3>@[Link]</h3>
<a asp-action="Start" asp-route-id="@[Link]">Start Quiz</a>
</div>
}
Views/Quiz/[Link]
@model Quiz
<form asp-action="Submit" method="post">
@foreach (var question in [Link])
{
<div>
<h4>@[Link]</h4>
@foreach (var answer in [Link])
{
<input type="radio" name="answers[@[Link]]" value="@[Link]" />
@[Link] <br />
}
</div>
}
<button type="submit">Submit Quiz</button>
</form>
Views/Quiz/[Link]
<h2>Quiz Completed!</h2>
<p>Your Score: @[Link] / @[Link]</p>
<a href="/">Back to Quizzes</a>

6. Database Migration
dotnet ef migrations add InitialCreate
dotnet ef database update

Page 39 of 56
Experiment-08

Create Web API (REST Service) in [Link] core using c#

Creating a Web API (REST Service) using [Link] Core and C# is a common way to
expose data and functionality over HTTP for frontend apps, mobile apps.

Project Overview

We’ll create a simple Products API that performs CRUD operations.

1. Create the Project


dotnet new webapi -n ProductApi
cd ProductApi

2. Create the Model

Models/[Link]:
namespace [Link]
{
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
}
}

3. Create the DbContext

Data/[Link]:
using [Link];
using [Link];

namespace [Link]
{
public class ApplicationDbContext : DbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options) {}

public DbSet<Product> Products { get; set; }


}
Page 40 of 56
}

4. Register DbContext in [Link]

Modify [Link] to use EF Core and SQLite (or SQL Server):


using [Link];
using [Link];

var builder = [Link](args);

// Register EF Core
[Link]<ApplicationDbContext>(options =>
[Link]("Data Source=[Link]"));

// Register services
[Link]();

var app = [Link]();

// Middleware
[Link]();
[Link]();
[Link]();

// Create DB on startup
using (var scope = [Link]())
{
var db = [Link]<ApplicationDbContext>();
[Link]();
}

[Link]();

5. Create the Controller

Controllers/[Link]:
using [Link];
using [Link];
using [Link];
using [Link];

namespace [Link]
{
[Route("api/[controller]")]
[ApiController]

Page 41 of 56
public class ProductsController : ControllerBase
{
private readonly ApplicationDbContext _context;

public ProductsController(ApplicationDbContext context)


{
_context = context;
}

[HttpGet]
public async Task<ActionResult<IEnumerable<Product>>> GetProducts()
{
return await _context.[Link]();
}

[HttpGet("{id}")]
public async Task<ActionResult<Product>> GetProduct(int id)
{
var product = await _context.[Link](id);
if (product == null)
return NotFound();
return product;
}

[HttpPost]
public async Task<ActionResult<Product>> PostProduct(Product product)
{
_context.[Link](product);
await _context.SaveChangesAsync();
return CreatedAtAction(nameof(GetProduct), new { id = [Link] }, product);
}

[HttpPut("{id}")]
public async Task<IActionResult> PutProduct(int id, Product product)
{
if (id != [Link])
return BadRequest();

_context.Entry(product).State = [Link];
await _context.SaveChangesAsync();
return NoContent();
}

[HttpDelete("{id}")]
public async Task<IActionResult> DeleteProduct(int id)
{
var product = await _context.[Link](id);
if (product == null)
Page 42 of 56
return NotFound();

_context.[Link](product);
await _context.SaveChangesAsync();
return NoContent();
}
}
}

6. Run the API

The API will be available at:


[Link]

You can test it using:

• Postman
• curl
• Swagger (enabled by default in new projects)

Page 43 of 56
Experiment-09

Create a Blazor Web App that support both server side rendering and client
interactivity.

To create a Blazor Web App that supports both server-side rendering (SSR) and client-
side interactivity, you’ll use the Blazor Web App template introduced in .NET 8. This
combines the power of Razor Components (SSR) with the interactivity of Blazor
WebAssembly (WASM) using Blazor Server + WebAssembly Hybrid (Auto mode).

What You'll Build

• A Blazor Web App (.NET 8)


• Server-rendered pages for fast load
• Client interactivity using WebAssembly
• Uses C#, Razor components, and SignalR

Prerequisites

• .NET 8 SDK
• Visual Studio 2022 (v17.8+) or VS Code

Project Setup
1. Create the Project
dotnet new blazor --name BlazorHybridApp --output BlazorHybridApp
cd BlazorHybridApp

This creates a Blazor Web App (Auto rendering).

2. Project Structure Overview


BlazorHybridApp/
├── Components/
│ └── [Link]
├── Pages/
│ ├── [Link]
│ └── [Link]
├── [Link]
├── _Imports.razor
├── [Link]
└── wwwroot/

Page 44 of 56
Key Features
[Link]

This file controls the layout and routing behavior:


<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>

Pages/[Link]
@page "/"
<h1>Hello from Blazor Web App!</h1>

<HelloWorld />

Components/[Link]
<h3>Hello from a component!</h3>

<button @onclick="IncrementCount">Click me</button>


<p>You clicked @count times.</p>

@code {
private int count = 0;

private void IncrementCount()


{
count++;
}
}

This component is server-rendered on first load and becomes interactive on the client.

[Link] (default setup)


var builder = [Link](args);

// Add Razor Components


[Link]()

Page 45 of 56
.AddInteractiveServerComponents()
.AddInteractiveWebAssemblyComponents();

var app = [Link]();

[Link]();
[Link]();

[Link]<App>()
.AddInteractiveServerRenderMode()
.AddInteractiveWebAssemblyRenderMode();

[Link]();

Run the App


dotnet run

Open your browser to [Link] (or your assigned port).


You’ll see a Blazor page that loads fast (SSR) and becomes interactive (via
WASM/SignalR).

Optional: Switch to WASM Only or Server Only

You can modify [Link] or rendering modes in [Link] to control how each
component renders.

Page 46 of 56
Experiment-10

Create a project based on User Staff Registration on [Link] and Deployment on


web server.

Creating a User Staff Registration System in [Link] Core MVC (C#) and
deploying it to a web server involves:

1. Building a secure, user-friendly registration and management system.


2. Using Entity Framework Core for the database.
3. Deploying it to a web host (e.g., IIS, Azure, or any Linux/Windows web server).

Project Overview

Features

• Register new staff users.


• View and manage staff records (CRUD).
• Validation and error handling.
• Deployable on a real web server.

Project Setup Steps

1. Create a New [Link] Core MVC Project


dotnet new mvc -n StaffRegistrationApp
cd StaffRegistrationApp

2. Create the Staff Model

Models/[Link]:
using [Link];

public class Staff


{
Page 47 of 56
public int Id { get; set; }

[Required]
[Display(Name = "Full Name")]
public string FullName { get; set; }

[Required]
[EmailAddress]
public string Email { get; set; }

[Required]
[Phone]
public string Phone { get; set; }

[Required]
[Display(Name = "Department")]
public string Department { get; set; }
}

3. Create the DbContext

Data/[Link]:
using [Link];

public class ApplicationDbContext : DbContext


{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options) { }
public DbSet<Staff> Staffs { get; set; }
}

Page 48 of 56
4. Configure [Link] for DB Access

[Link]<ApplicationDbContext>(options =>
[Link]("Data Source=[Link]")); // Or use SQL Server

5. Create Staff Controller

Controllers/[Link]:
using [Link];
using [Link];

public class StaffController : Controller


{
private readonly ApplicationDbContext _context;

public StaffController(ApplicationDbContext context)


{
_context = context;
}

public async Task<IActionResult> Index()


{
return View(await _context.[Link]());
}

public IActionResult Create() => View();

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create(Staff staff)
{
if ([Link])
Page 49 of 56
{
_context.Add(staff);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(staff);
}

public async Task<IActionResult> Edit(int id)


{
var staff = await _context.[Link](id);
return staff == null ? NotFound() : View(staff);
}

[HttpPost]
public async Task<IActionResult> Edit(int id, Staff staff)
{
if (id != [Link]) return NotFound();

if ([Link])
{
_context.Update(staff);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(staff);
}

public async Task<IActionResult> Delete(int id)


{
var staff = await _context.[Link](id);
return staff == null ? NotFound() : View(staff);

Page 50 of 56
}

[HttpPost, ActionName("Delete")]
public async Task<IActionResult> DeleteConfirmed(int id)
{
var staff = await _context.[Link](id);
_context.[Link](staff);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
}

6. Create Views for Staff

Views/Staff/:

• [Link]
• [Link]
• [Link]
• [Link]

Use Visual Studio scaffolding or manually build forms using Razor.

7. Run EF Core Migration

dotnet ef migrations add InitialCreate


dotnet ef database update

Deployment Options

Page 51 of 56
Option 1: Deploy to IIS

• Publish with dotnet publish -c Release.


• Deploy the contents of publish/ to IIS.
• Make sure .NET Core Hosting Bundle is installed.

Option 2: Deploy to Azure

dotnet publish -o out


# Use Azure Portal or Azure CLI to deploy folder contents.

Option 3: Docker or Linux Server


FROM [Link]/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80

FROM [Link]/dotnet/sdk:8.0 AS build


WORKDIR /src
COPY . .
RUN dotnet publish -c Release -o /app/publish

FROM base AS final


WORKDIR /app
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "[Link]"]

Page 52 of 56
Experiment-11

Create a project based on User Staff Registration on [Link] and Deployment on


web server using c# and IIS

To create a User Staff Registration system using [Link] Core (C#) and deploy it
on IIS, covers project creation, code implementation, database setup, and IIS
deployment.

Project Overview
Features:

• Register staff users.


• List, edit, and delete staff.
• [Link] Core MVC with EF Core (SQLite or SQL Server).
• Deploy to IIS on Windows.

1 Create the [Link] Core MVC Project


dotnet new mvc -n StaffRegistrationApp
cd StaffRegistrationApp

2 Define the Staff Model

Models/[Link]:
using [Link];

public class Staff


{
public int Id { get; set; }

[Required]
[Display(Name = "Full Name")]
public string FullName { get; set; }

[Required]
[EmailAddress]
public string Email { get; set; }

[Required]
[Phone]
public string Phone { get; set; }

[Required]
Page 53 of 56
public string Department { get; set; }
}

3 Create the ApplicationDbContext

Data/[Link]:
using [Link];

public class ApplicationDbContext : DbContext


{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options) { }

public DbSet<Staff> Staffs { get; set; }


}

4 Configure EF Core in [Link]

[Link]:
[Link]<ApplicationDbContext>(options =>
[Link]("Data Source=[Link]")); // Or UseSqlServer()

Also add:
[Link]();

5 Create Staff Controller

Controllers/[Link]:
using [Link];
using [Link];

public class StaffController : Controller


{
private readonly ApplicationDbContext _context;

public StaffController(ApplicationDbContext context) => _context = context;

public async Task<IActionResult> Index() =>


View(await _context.[Link]());

public IActionResult Create() => View();

[HttpPost]
[ValidateAntiForgeryToken]
Page 54 of 56
public async Task<IActionResult> Create(Staff staff)
{
if ([Link])
{
_context.Add(staff);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(staff);
}

public async Task<IActionResult> Edit(int id)


{
var staff = await _context.[Link](id);
return staff == null ? NotFound() : View(staff);
}

[HttpPost]
public async Task<IActionResult> Edit(int id, Staff staff)
{
if (id != [Link]) return NotFound();
if ([Link])
{
_context.Update(staff);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(staff);
}

public async Task<IActionResult> Delete(int id)


{
var staff = await _context.[Link](id);
return staff == null ? NotFound() : View(staff);
}

[HttpPost, ActionName("Delete")]
public async Task<IActionResult> DeleteConfirmed(int id)
{
var staff = await _context.[Link](id);
_context.[Link](staff);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}}

6 Create Views (Razor Pages)

Use Visual Studio scaffolding or create:


Page 55 of 56
• Views/Staff/[Link]
• Views/Staff/[Link]
• Views/Staff/[Link]
• Views/Staff/[Link]

Each form should be bound to Staff fields.

7 Setup Database

Install EF tools if needed:


dotnet tool install --global dotnet-ef

Run migrations:
dotnet ef migrations add InitialCreate
dotnet ef database update

8 Publish for IIS


dotnet publish -c Release -o ./publish

9 Deploy to IIS
Prerequisites

• Install .NET Hosting Bundle from [Link].


• Enable IIS, install [Link] Core Module, and restart server.
Setup IIS Site

1. Open IIS Manager.


2. Right-click Sites → Add Website.
3. Set:
o Site name: StaffRegistrationApp
o Physical path: publish folder path
o Port: 8080 or default 80
4. Use No Managed Code in app pool.
Permissions

Ensure IIS_IUSRS and NETWORK SERVICE have read/execute rights on publish


folder.

Browse Site

Go to [Link] or your assigned domain/IP.


Page 56 of 56

You might also like