DEV Community

Cover image for How I Built Live Exam Monitoring That Works With Zero Internet (SignalR + ASP.NET Core)
Anointed Agunloye
Anointed Agunloye

Posted on AI-assisted

How I Built Live Exam Monitoring That Works With Zero Internet (SignalR + ASP.NET Core)

Most schools I work with in Nigeria can't count on the internet during exams. Power flickers, data runs out, the network drops. But they still want computer-based tests, and they want the exam officer to see every student live: who has joined, what question they're on, whether they've switched tabs, and whether their laptop is about to die.

So I built Exam Box, an offline computer-based testing (CBT) platform that schools now use for their real exams. This post is about the part I'm proudest of: the live monitor that runs with no internet at all.

The setup: one PC is the server

There's no cloud. The exam officer installs a Windows desktop app (.NET 8 WPF), and that app hosts its own web server inside it:

+----------------------------------+
|        Admin PC (WPF app)        |
|                                  |
|  Admin UI  <-->  ASP.NET Core    |
|                  (Kestrel :5000) |
|                                  |
|  REST API  |  SignalR  |  SQLite |
+----------------------------------+
                  |
          school LAN / Wi-Fi
                  |
     +------------+------------+
     |            |            |
 [Browser]    [Browser]    [Browser]
 Student 1    Student 2    Student N
Enter fullscreen mode Exit fullscreen mode

The admin clicks Start Server, then Start Session, and gets a session code and a join URL like http://192.168.1.100:5000?code=A1B2C3. Students open that URL in any browser on the same network. Nothing to install on their machines.

Everything (exams, answers, results) lives in a local SQLite database through EF Core.

Real-time with SignalR groups

The live part is a single SignalR hub. The trick that made it clean was groups: each session gets an admin group and a student group, so one exam room never sees another room's traffic.

public class ExamHub : Hub
{
    public async Task JoinAdminGroup(string sessionCode) =>
        await Groups.AddToGroupAsync(Context.ConnectionId, $"admin_{sessionCode}");

    public async Task JoinStudentGroup(string sessionCode) =>
        await Groups.AddToGroupAsync(Context.ConnectionId, $"students_{sessionCode}");

    // Student did something -> only that session's admins hear about it
    public static Task NotifyStudentUpdate(IHubContext<ExamHub> hub, string sessionCode, object payload) =>
        hub.Clients.Group($"admin_{sessionCode}").SendAsync("StudentUpdated", payload);

    // Admin hits "End All" -> every student in the session auto-submits
    public static Task NotifyForceSubmit(IHubContext<ExamHub> hub, string sessionCode) =>
        hub.Clients.Group($"students_{sessionCode}").SendAsync("ForceSubmit");
}
Enter fullscreen mode Exit fullscreen mode

Messages flow both ways:

  • Student → admin: answering a question, switching tabs, connection and battery updates. The API saves it, then pushes StudentUpdated to the admin group.
  • Admin → students: exam started, session ended, force submit, or kicking one student back to login.

For that last one, every student also joins a private group just for them. To join it, the browser has to send its exam token, which the server validates first, so a student can't pretend to be someone else:

public async Task<bool> JoinStudentSelf(string token)
{
    var id = StudentTokens.Validate(token);
    if (id is null) return false;              // forged or expired token joins nothing
    await Groups.AddToGroupAsync(Context.ConnectionId, SelfGroup(id.Value));
    return true;
}
Enter fullscreen mode Exit fullscreen mode

What the exam officer actually sees

The Monitor tab updates live for each student:

  • questions answered and current question
  • time left
  • connection status and battery level
  • tab switches and other violations

When the exam ends, results are ready immediately. No collating scripts, no manual marking.

Lessons from running it in real schools

1. Always have a fallback for the realtime channel.
School Wi-Fi is messy, and WebSocket connections drop. On the student side I reconnect automatically and re-join the private group, and if SignalR can't connect at all, a regular heartbeat request keeps the admin's view up to date:

examHub.onreconnected(joinSelf);
examHub.start()
  .then(joinSelf)
  .catch(() => { /* offline — heartbeat poll is the fallback */ });
Enter fullscreen mode Exit fullscreen mode

2. Save progress on every answer.
Every answer is saved to the server as the student goes. If a laptop dies mid-exam, the student logs back in and continues from the same question, with the same answers and the same timer.

3. Never send the answer to the browser.
Questions and options are shuffled per student (Fisher-Yates). The server tracks the correct answer by value, not by position, and the student's page never receives it.

4. Firewalls will get you.
The most common support issue wasn't code at all: Windows Firewall blocking port 5000. Now that's the first thing in the troubleshooting guide.

Wrapping up

You don't always need the cloud to build something real-time. A desktop app hosting ASP.NET Core and SignalR on the local network turned out to be the right tool for schools that can't count on the internet, and it now runs live exams in real schools.

If you've built something real-time for unreliable networks, I'd love to hear how you handled reconnects. Drop it in the comments.

Top comments (2)

Collapse
 
userxnom profile image
Abdullah Naseer •

This is the kind of real-time work that actually matters — building for schools where the internet can't be assumed, not for a demo with perfect Wi-Fi. The SignalR groups design is clean, especially the private per-student group for force-submit, and 'never send the answer to the browser' with per-student Fisher-Yates shuffling is the right call for an exam. The lesson that stuck with me most is the firewall one: the most common support issue being Windows Firewall on port 5000, not code at all. When a student's laptop dies mid-exam and they log back in, how do you handle the clock — does their timer pause, or does the server keep it running from the original start?

Collapse
 
anointedthedeveloper profile image
Anointed Agunloye •

Thanks Abdullah! The timer pauses, and the clock lives on the server, not in the browser.

The exam page pings the server every few seconds. Each ping adds the time since the last one to that student's ElapsedSeconds, but only if the gap is under 60s:

var gap = now - se.LastSeenAt;
if (gap <= TimeSpan.FromSeconds(60)) se.ElapsedSeconds += gap.TotalSeconds;
se.LastSeenAt = now;
Enter fullscreen mode Exit fullscreen mode

So if a laptop is dead for 10 minutes, those 10 minutes aren't charged. When the student logs back in, the server sends back remainingSeconds = duration − elapsed.

Their work survives too: every answer is saved to SQLite the moment they pick it, their current question is saved with each ping, and the shuffle is seeded per attempt. They come back to the same question order, the same answers and the same spot.

Because the server owns the clock, refreshing or changing the PC's clock can't buy extra time. Answers that arrive after the deadline (plus a 2-minute grace for slow networks) are ignored.