BSc CSIT (TU) Science NET Centric Computing (BSc CSIT, CSC367) Question Paper 2078 Nepal
This is the official BSc CSIT (TU) (Science stream) NET Centric Computing (BSc CSIT, CSC367) question paper for 2078, as set in the regular annual examination. It carries 60 full marks and a time allowance of 180 minutes, across 12 questions. On Kekkei you can attempt this NET Centric Computing (BSc CSIT, CSC367) past paper online with a timer, get instant AI feedback and step-by-step solutions, and track the topics where you lose marks — completely free. Whether you are revising for your BSc CSIT (TU) NET Centric Computing (BSc CSIT, CSC367) exam or solving previous years' question papers, this 2078 paper is a great way to practise under real exam conditions.
Section A: Long Answer Questions
Attempt any TWO questions.
Explain Razor view engine. Discuss layouts, partial views, view components and tag helpers with examples.
Razor View Engine
The Razor view engine is the default templating engine in ASP.NET Core MVC. It lets you embed server-side C# code inside HTML markup using the @ symbol, producing dynamic HTML at runtime. Razor view files use the .cshtml extension. The engine is concise (no explicit open/close blocks needed in most cases), supports IntelliSense, and intelligently switches between C# and HTML.
<h2>Hello @Model.Name</h2>
@if (Model.IsAdmin) {
<p>Welcome, administrator!</p>
}
@foreach (var item in Model.Items) {
<li>@item</li>
}
1. Layouts
A layout (_Layout.cshtml) defines the common structure (header, footer, navigation, <head> links) shared by many views, avoiding duplication. The view's content is injected via @RenderBody(), and optional sections via @RenderSection().
<!-- _Layout.cshtml -->
<html>
<head><title>@ViewData["Title"]</title></head>
<body>
<nav>My Site</nav>
<div>@RenderBody()</div>
@RenderSection("Scripts", required: false)
</body>
</html>
A view selects a layout with @{ Layout = "_Layout"; } (often set globally in _ViewStart.cshtml).
2. Partial Views
A partial view is a reusable .cshtml fragment (e.g. _ProductCard.cshtml) rendered inside another view. It is used to break large views into reusable pieces such as a product card or a comment block.
<partial name="_ProductCard" model="product" />
3. View Components
A view component is like a mini-controller + partial view. Unlike a partial, it contains its own logic and does not depend on the parent's model — ideal for self-contained widgets (login panel, shopping cart, dynamic menu).
public class CartViewComponent : ViewComponent {
public IViewComponentResult Invoke() {
var items = _cart.GetItems();
return View(items); // renders Views/Shared/Components/Cart/Default.cshtml
}
}
@await Component.InvokeAsync("Cart")
4. Tag Helpers
Tag helpers are server-side components that attach to HTML elements to generate markup, replacing the older @Html helpers with cleaner HTML-like syntax. Example built-in tag helpers: asp-for, asp-action, asp-controller, asp-validation-for.
<form asp-controller="Account" asp-action="Login" method="post">
<input asp-for="Email" />
<span asp-validation-for="Email"></span>
<a asp-controller="Home" asp-action="Index">Home</a>
</form>
Tag helpers are enabled by @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers in _ViewImports.cshtml.
Summary
Razor cleanly mixes C# and HTML; layouts give a shared shell, partial views reuse markup, view components encapsulate logic + view for widgets, and tag helpers make HTML generation declarative and readable.
Describe the MVC design pattern. Explain the architecture and design principles of the ASP.NET Core framework with a diagram.
The MVC Design Pattern
Model–View–Controller (MVC) is an architectural pattern that separates an application into three interconnected components to achieve separation of concerns, testability and maintainability.
- Model — represents the application data and business logic (domain objects, validation, database access).
- View — the presentation layer; renders the UI (Razor
.cshtmlpages) from the data supplied to it. - Controller — handles incoming HTTP requests, interacts with the Model, selects a View, and returns the response. It is the coordinator between Model and View.
Flow (text diagram)
Browser (HTTP request)
|
v
+------------+ reads/updates +---------+
| Controller | <-------------------> | Model |
+------------+ +---------+
| selects view + passes model
v
+---------+ renders HTML
| View | ----------------------> Browser (HTTP response)
+---------+
The user interacts with the View; the Controller processes the action; the Model is updated; the View re-renders.
ASP.NET Core Framework Architecture
ASP.NET Core is a cross-platform, open-source, high-performance framework for building web apps and APIs. Key architectural elements:
- Kestrel web server — the built-in cross-platform HTTP server, usually behind a reverse proxy (IIS/Nginx).
- Middleware pipeline — the request flows through an ordered chain of middleware components (routing, authentication, authorization, static files, MVC/endpoints). Each middleware can process the request and the response.
- Dependency Injection (DI) — built-in IoC container; services are registered in
Program.csand injected into controllers. - Configuration — unified config from
appsettings.json, environment variables, etc. - Routing & Endpoints — maps URLs to controller actions / Razor pages.
Client -> Kestrel -> [ Middleware Pipeline:
StaticFiles -> Routing -> Authentication
-> Authorization -> Endpoint(MVC) ] -> Controller
-> Model -> View -> Response
Design Principles
- Cross-platform (Windows, Linux, macOS) and modular (NuGet packages).
- Separation of concerns via MVC and middleware.
- Dependency Injection as a first-class citizen (loose coupling, testability).
- Convention over configuration (e.g.
/Controller/Actionrouting). - High performance & lightweight (async I/O, minimal allocations).
- Unified MVC + Web API programming model.
Conclusion
MVC organises code into Model, View and Controller for clean separation, while ASP.NET Core implements it on a modular, cross-platform stack built around Kestrel, a configurable middleware pipeline and built-in dependency injection.
Write methods to insert, update, delete and read data using Entity Framework Core in an ASP.NET Core application.
CRUD with Entity Framework Core
Entity Framework (EF) Core is an ORM that maps C# entity classes to database tables via a DbContext. Below are methods for Create, Read, Update and Delete using a Product entity.
DbContext and Entity
public class Product {
public int Id { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
}
public class AppDbContext : DbContext {
public AppDbContext(DbContextOptions<AppDbContext> opts) : base(opts) { }
public DbSet<Product> Products { get; set; }
}
Insert (Create)
public async Task InsertAsync(Product product) {
_context.Products.Add(product);
await _context.SaveChangesAsync();
}
Read
// All records
public async Task<List<Product>> GetAllAsync() =>
await _context.Products.ToListAsync();
// Single record by id
public async Task<Product?> GetByIdAsync(int id) =>
await _context.Products.FindAsync(id);
Update
public async Task UpdateAsync(Product product) {
_context.Products.Update(product); // marks entity as Modified
await _context.SaveChangesAsync();
}
Delete
public async Task DeleteAsync(int id) {
var product = await _context.Products.FindAsync(id);
if (product != null) {
_context.Products.Remove(product);
await _context.SaveChangesAsync();
}
}
Notes
_contextis an injectedAppDbContext.SaveChangesAsync()commits the tracked changes to the database in one transaction.- EF Core tracks entity states (
Added,Modified,Deleted,Unchanged) and generates the corresponding SQL. - These methods are typically called from a controller action or a repository/service layer.
Section B: Short Answer Questions
Attempt any EIGHT questions.
Explain the difference between TempData, ViewData and ViewBag.
TempData vs ViewData vs ViewBag
All three pass data from a controller to a view, but differ in lifetime and type.
| Feature | ViewData | ViewBag | TempData |
|---|---|---|---|
| Type | ViewDataDictionary (key–value) | dynamic wrapper over ViewData | ITempDataDictionary (key–value) |
| Syntax | ViewData["Msg"] | ViewBag.Msg | TempData["Msg"] |
| Casting | Needs explicit cast | No cast (dynamic) | Needs explicit cast |
| Lifetime | Current request only | Current request only | Persists to the next request (uses session) |
| Typical use | Pass data controller → view | Same as ViewData, cleaner syntax | Pass data across a redirect (e.g. PRG pattern, flash messages) |
Key points:
ViewDataandViewBagare two faces of the same data — both live only for the current request and becomenullafter a redirect.TempDatasurvives a redirect because it is backed by session/cookie storage; once read it is normally removed (useKeep()/Peek()to retain).
ViewData["Title"] = "Home";
ViewBag.Message = "Welcome";
TempData["Status"] = "Saved successfully"; // available after RedirectToAction
What is LINQ? Write a LINQ query to filter a list of integers.
LINQ
LINQ (Language-Integrated Query) is a feature of C#/.NET that provides a uniform, strongly-typed syntax for querying data from different sources — in-memory collections (LINQ to Objects), databases (LINQ to Entities / EF Core), XML, etc. — directly in the language. It supports compile-time checking, IntelliSense, and both query syntax and method (fluent) syntax.
Filter a list of integers (even numbers)
Query syntax:
List<int> numbers = new() { 1, 2, 3, 4, 5, 6, 7, 8 };
var evens = from n in numbers
where n % 2 == 0
select n;
// evens -> 2, 4, 6, 8
Method syntax (equivalent):
var evens = numbers.Where(n => n % 2 == 0).ToList();
foreach (var n in evens) Console.WriteLine(n); // 2 4 6 8
The Where operator uses a lambda predicate n => n % 2 == 0 to keep only the elements that satisfy the condition. LINQ uses deferred execution — the query runs when enumerated (e.g. by ToList() or foreach).
Explain the lifecycle of a request in ASP.NET Core MVC.
Request Lifecycle in ASP.NET Core MVC
When an HTTP request arrives, it passes through the following stages:
- Web server (Kestrel) receives the request, optionally via a reverse proxy (IIS/Nginx).
- Middleware pipeline — the request flows through ordered middleware: exception handling, HTTPS redirection, static files, routing, authentication, authorization, etc. Each may short-circuit or modify the request/response.
- Routing — the routing middleware matches the request URL to an endpoint (a controller action) using route templates or attribute routes.
- Controller selection & action invocation — the MVC framework creates the controller (via DI), runs model binding (mapping form/query/route data to action parameters) and model validation.
- Filters run around the action: authorization filters → resource filters → action filters → the action method → result filters → exception filters.
- Action execution — the action runs business logic, talks to the model/services, and returns an
IActionResult(e.g.ViewResult,JsonResult,RedirectResult). - Result execution — for a
ViewResult, the Razor view engine renders the.cshtmlview into HTML. - Response travels back out through the middleware pipeline (in reverse) to the client.
Request -> Kestrel -> Middleware -> Routing -> Model Binding/Validation
-> Filters -> Action -> Result (View render) -> Response
This pipeline gives well-defined hooks (middleware and filters) for cross-cutting concerns such as logging, authentication and caching.
What is the difference between AddSingleton, AddScoped and AddTransient?
Service Lifetimes: Singleton vs Scoped vs Transient
In ASP.NET Core's dependency-injection container, these three methods register a service with different lifetimes (how often a new instance is created).
| Method | Lifetime | Instance created |
|---|---|---|
AddTransient<T>() | Transient | A new instance every time the service is requested. |
AddScoped<T>() | Scoped | One instance per request (HTTP request / DI scope); shared within that request. |
AddSingleton<T>() | Singleton | One instance for the entire application lifetime; shared by all requests. |
builder.Services.AddTransient<IMailService, MailService>();
builder.Services.AddScoped<IRepository, Repository>();
builder.Services.AddSingleton<ICacheService, CacheService>();
Guidelines:
- Transient — lightweight, stateless services.
- Scoped — services that should be consistent within a single request, e.g. EF Core
DbContext. - Singleton — stateless shared services like caching, configuration, logging.
Caution: never inject a scoped (or transient) service into a singleton — it would be captured for the app's lifetime and cause subtle bugs (captive dependency).
Explain garbage collection in the .NET framework.
Garbage Collection in .NET
Garbage collection (GC) is the automatic memory-management service of the .NET Common Language Runtime (CLR). It reclaims memory occupied by managed objects on the managed heap that are no longer reachable by the application, so developers do not have to free memory manually (no delete/free), which prevents most memory leaks and dangling-pointer errors.
How it works
- When an object is created, memory is allocated on the managed heap.
- The GC periodically determines which objects are still reachable (referenced directly or indirectly by roots: static fields, local variables, CPU registers). Unreachable objects are considered garbage.
- The GC reclaims their memory and compacts the heap (moving surviving objects together) to reduce fragmentation.
Generations
The .NET GC is generational for efficiency:
- Gen 0 — short-lived objects; collected most frequently and cheaply.
- Gen 1 — buffer between short- and long-lived objects.
- Gen 2 — long-lived objects (and the Large Object Heap); collected least often.
Objects that survive a collection are promoted to the next generation. Most objects die young, so collecting Gen 0 frequently is fast.
Finalization / Dispose
- Objects holding unmanaged resources (files, sockets, DB connections) should implement
IDisposableand be released viaDispose()/using, because the GC only manages memory, not unmanaged resources.
GC trades a small, non-deterministic runtime overhead for safety and developer productivity.
What is a partial view? When is it used?
Partial View
A partial view is a reusable Razor view file (.cshtml, conventionally named with a leading underscore, e.g. _LoginForm.cshtml) that renders a fragment of HTML inside another (parent) view. It does not have its own layout and is meant to be embedded, not requested directly.
When it is used
- To avoid duplication of markup that appears in many views (e.g. a product card, comment block, navigation menu).
- To break a large view into smaller, manageable pieces.
- To render the same UI fragment across multiple pages consistently.
- To return just a fragment via AJAX (e.g. refresh a list without reloading the page).
How to render it
<!-- Tag helper (recommended) -->
<partial name="_ProductCard" model="Model.Product" />
<!-- HTML helper -->
@Html.Partial("_ProductCard", Model.Product)
@await Html.PartialAsync("_ProductCard", Model.Product)
A partial view receives its data from the parent view's model or via ViewData. (For self-contained widgets that need their own logic/data, a view component is preferred instead.)
Explain the difference between authentication and authorization in ASP.NET Core.
Authentication vs Authorization
Both are security concerns in ASP.NET Core but answer different questions.
| Authentication | Authorization | |
|---|---|---|
| Question answered | Who are you? | What are you allowed to do? |
| Purpose | Verifies the identity of a user (credentials, token, cookie) | Determines whether an authenticated user may access a resource/action |
| Order | Happens first | Happens after authentication |
| Mechanism in ASP.NET Core | Authentication middleware/schemes (Cookie, JWT Bearer, Identity); UseAuthentication() | Policies, roles, claims; [Authorize] attribute, UseAuthorization() |
| Result | Produces a ClaimsPrincipal (the logged-in user) | Grants or denies access (e.g. 403 Forbidden) |
Example:
app.UseAuthentication(); // identify the user
app.UseAuthorization(); // check their permissions
[Authorize(Roles = "Admin")] // only authenticated Admin users
public IActionResult Dashboard() => View();
Summary: Authentication establishes who the user is; authorization decides whether that user is permitted to perform the requested action. Authentication always precedes authorization.
What is asynchronous programming in C#? Explain async and await.
Asynchronous Programming in C#
Asynchronous programming lets a program start a long-running operation (I/O such as file, network or database access) and continue without blocking the calling thread, freeing it to do other work until the operation completes. This improves scalability and responsiveness — e.g. a web server can handle more requests because threads are not blocked waiting on I/O. C# implements it with the async / await keywords and the Task-based Asynchronous Pattern (TAP).
async
- The
asyncmodifier marks a method as asynchronous, enabling the use ofawaitinside it. - An
asyncmethod typically returnsTask,Task<T>(orValueTask), and runs synchronously until it hits the firstawait.
await
- The
awaitoperator suspends the method until the awaitedTaskcompletes, without blocking the thread. Control returns to the caller; when the task finishes, execution resumes after theawait, and the result is unwrapped.
Example
public async Task<string> GetDataAsync() {
using var client = new HttpClient();
// thread is released while the request is in flight
string result = await client.GetStringAsync("https://api.example.com/data");
return result; // resumes here when the download completes
}
Key points: await does not create a new thread; it releases the current thread while waiting on I/O. Async methods should generally return Task/Task<T> (avoid async void except for event handlers), and the chain should be async "all the way".
Explain the use of migrations in Entity Framework Core.
Migrations in Entity Framework Core
A migration in EF Core is a way to incrementally evolve the database schema to keep it in sync with the application's entity (model) classes, while preserving existing data. Instead of manually writing SQL DDL, EF Core generates migration code from changes you make to your models.
Why migrations are used
- Keep the database schema in sync with C# model changes.
- Apply schema changes in a versioned, repeatable, source-controlled way.
- Move changes safely across environments (dev → test → production).
- Roll back to a previous schema if needed.
Workflow / commands
- Create a migration — EF compares the current model with the last snapshot and generates
Up()(apply) andDown()(revert) methods:
dotnet ef migrations add InitialCreate
- Apply the migration to the database (creates/updates tables):
dotnet ef database update
- Add further migrations as the model changes (e.g. add a column):
dotnet ef migrations add AddEmailToUser
dotnet ef database update
- Revert / remove if needed:
dotnet ef database update PreviousMigrationName
dotnet ef migrations remove
EF Core records applied migrations in a __EFMigrationsHistory table so it knows which migrations still need to run. This supports the code-first approach where the database is derived from the model.
Frequently asked questions
- Where can I find the BSc CSIT (TU) NET Centric Computing (BSc CSIT, CSC367) question paper 2078?
- The full BSc CSIT (TU) NET Centric Computing (BSc CSIT, CSC367) 2078 (regular) question paper is available free on Kekkei. You can read every question online and attempt the paper under timed exam conditions.
- Does the NET Centric Computing (BSc CSIT, CSC367) 2078 paper come with solutions?
- Yes. Every question on this NET Centric Computing (BSc CSIT, CSC367) past paper includes a step-by-step solution, plus instant AI feedback when you attempt it on Kekkei.
- How many marks is the BSc CSIT (TU) NET Centric Computing (BSc CSIT, CSC367) 2078 paper?
- The BSc CSIT (TU) NET Centric Computing (BSc CSIT, CSC367) 2078 paper carries 60 full marks and is meant to be completed in 180 minutes, across 12 questions.
- Is practising this NET Centric Computing (BSc CSIT, CSC367) past paper free?
- Yes — reading and attempting this NET Centric Computing (BSc CSIT, CSC367) past paper on Kekkei is completely free.