11 - Debugging Guide

Tools, techniques, and checklists for diagnosing issues in the .NET backend.

Swagger Explorer

The fastest way to test any endpoint without the Flutter app.

Hangfire Dashboard

Watch background jobs in real-time.

Serilog Console Output

All logs go to the console in dev mode via Serilog. Structured logs with CorrelationId enrichment for tracing across requests.

LogTypical log output
[16:22:14 INF] Lead 8f2a1c9e: Starting OTP verification [CorrelationId: a3f4...]
[16:22:14 INF] Lead 8f2a1c9e: OTP verified successfully. State=OTP_VERIFIED [CorrelationId: a3f4...]
[16:22:14 INF] Lead 8f2a1c9e: Bank auto-verify triggered via Decentro (first time) [CorrelationId: a3f4...]
[16:22:14 INF] Lead 8f2a1c9e: Bank auto-verify MOCKED [CorrelationId: a3f4...]
[16:22:14 INF] HTTP POST /api/v1/registration/otp/verify responded 200 in 83ms [CorrelationId: a3f4...]

EF Core Query Logs

Enable SQL query logging by setting Microsoft.EntityFrameworkCore.Database.Command: Information in appsettings.Development.json. Every generated SQL statement will appear in the console.

appsettings.Development.jsonJSON
{
  "Logging": {
    "LogLevel": {
      "Default": "Debug",
      "Microsoft.AspNetCore": "Information",
      "Microsoft.EntityFrameworkCore.Database.Command": "Information"
    }
  }
}

API Audit Log Table

Every external provider call is logged to ekyc.api_audit_log. Query this when you want to see what the backend sent to an external provider and what came back.

SQLInspect audit log
SELECT provider, api_name, method, response_status_code, duration_ms, is_success, is_mock, error_message, created_at
FROM ekyc.api_audit_log
WHERE lead_id = '8f2a1c9e-...'
ORDER BY created_at DESC;

Journey Activity Log Table

Human-readable per-lead timeline populated by ActivityLogWriterService. Shows every significant event in the user journey.

SQLInspect activity log
SELECT stage_number, stage_name, category, severity, message, provider, is_success, created_at
FROM ekyc.journey_activity_logs
WHERE lead_id = '8f2a1c9e-...'
ORDER BY created_at;

Breakpoints (Visual Studio / Rider)

  1. Open the solution backend/MO.Ekyc.sln
  2. Set startup project to MO.Ekyc.Api
  3. Set breakpoints in controller actions or service methods
  4. F5 (Run with debugger)
  5. Make a request from Swagger or the Flutter app
  6. Step through with F10 / F11
Recommended breakpoints

Set one in ProviderChainExecutor.ExecuteAsync to watch every external call flow. Set one in any RequiresStage-decorated controller to observe the filter running.

Common Issues Checklists

"500 Internal Server Error"

"409 Conflict" from StageValidationFilter

"401 Unauthorized"

"403 Forbidden" on admin endpoints

"Schema 'ekyc' does not exist"

External provider call returns real data in mock mode

Hangfire jobs stuck in "Enqueued"

Postman / curl Testing

BashFull journey via curl
# Step 1: Arrival
curl "http://localhost:5000/api/v1/journey/init?device_type=DESKTOP"

# Step 2: Signup
curl -X POST http://localhost:5000/api/v1/registration/signup \
  -H "Content-Type: application/json" \
  -d '{"mobileNumber":"9876543210","fullName":"Test User","consentTerms":true,"consentBankAutoverify":true}'

# Step 3: Verify OTP (fixed 1234 in mock mode)
curl -X POST http://localhost:5000/api/v1/registration/otp/verify \
  -H "Content-Type: application/json" \
  -H "X-Lead-Id: <leadId-from-step-2>" \
  -d '{"leadId":"...","otp":"1234"}'