untitled

Pasted Oct 26, 2026, 2:12 AM1 file73 lines

Scan to open on your phone

Point a camera at the QR code - it opens this exact paste, no app needed.

https://codepastes.com/p05
untitled
5a
cookies
name = txtName, save = btnSave, show = btnShow, op = lblOutput
save btn
protected void btnSave_Click(object sender, EventArgs e)
 {
 // Session Cookie - Browser band hone par delete ho jayega
 HttpCookie sessionCookie = new HttpCookie("SessionUser");
 sessionCookie.Value = txtName.Text;
 Response.Cookies.Add(sessionCookie);
 // Persistent Cookie - 7 din tak rahega
 HttpCookie persistentCookie = new HttpCookie("PersistentUser");
 persistentCookie.Value = txtName.Text;
 persistentCookie.Expires = DateTime.Now.AddDays(7);
 Response.Cookies.Add(persistentCookie);
 lblOutput.Text = "Cookies Saved Successfully";
 }
}
Show btn
 protected void btnShow_Click(object sender, EventArgs e)

{
 string sessionData = Request.Cookies["SessionUser"].Value;
 string persistentData = Request.Cookies["PersistentUser"].Value;
 lblOutput.Text = "Session Cookie: " + sessionData +
 "<br/>Persistent Cookie: " + persistentData;
}

CRUD
MVC
Model -Employee
{
 public class Employee
 {
 public int Id { get; set; }
 public string Name { get; set; }
 public string Department { get; set; }
 public double Salary { get; set; }
 }
}
dataFolder - AppDbContext.cs
namespace EmployeeCRUD.Models
using EmployeeCRUD.Models;
using Microsoft.EntityFrameworkCore;
namespace EmployeeCRUD.Data
{
 public class AppDbContext : DbContext
 {
 public AppDbContext(DbContextOptions<AppDbContext> options)
 : base(options)
 {}
 public DbSet<Employee> Employees { get; set; }
 }
}
appsettings.json
ConnectionStrings": {
 "MyConnection":
"Server=(localdb)\\MSSQLLocalDB;Database=EmployeeDB;Trusted_Connection=True;TrustServ
erCertificate=True",
 "AppDbContext":
"Server=(localdb)\\mssqllocaldb;Database=AppDbContext;Trusted_Connection=True;MultipleAc
tiveResultSets=true"
}
Program.cs
using Microsoft.EntityFrameworkCore;
using EmployeeCRUD.Data;
Before:
Var app=builder.Bulid();
Add:
builder.Services.AddDbContext<AppDbContext>(options =>
options.UseSqlServer(
builder.Configuration.GetConnectionString("MyConnection")));
 

1,997 chars · codepastes.com