Support Thread

Fix: Crash When Switching to Mobile Theme in APG vNext

Fix: Crash When Switching to Mobile Theme in APG vNext — APG vNext Guide

Some users reported a crash or unhandled exception error when switching from the desktop theme to the mobile theme in APG vNext 4.3 and earlier versions.

Symptoms

  • Yellow screen of death (YSOD) when navigating to the forum on a mobile device
  • Error occurs specifically after the theme switching logic fires
  • Error message typically references a null reference in the theme loader

Cause

The issue was caused by a race condition in the theme detection module when the session was not yet fully initialized. Under certain load conditions, the theme switcher attempted to access session data before it was available.

Fix

This issue is fixed in APG vNext 4.4. The theme switching logic was updated to properly check for session availability before attempting to read theme preferences.

To resolve this without upgrading, add a null check to the theme handler in App_Code/ThemeHandler.cs:

  • Upgrade to APG vNext 4.4 (recommended) — see the 4.4 release notes.
  • Or apply the patch file available in the support forum.

See the Support Forum for more details.

APG vNext Crashes When Switching to Mobile Theme - Fix

Some APG vNext installations crash with a 500 error or blank page when the mobile theme is manually selected via the theme switcher. This is almost always caused by missing mobile skin files or a misconfigured mobile skin path in web.config.

Diagnosing the Crash

-- Check IIS logs for the 500 error detail:
-- C:/inetpub/logs/LogFiles/W3SVC1/u_exYYMMDD.log
-- Also check: Admin Panel -> System -> Error Log

Common Cause: Missing Mobile Skin Files

The mobile skin must exist at the configured path. Check:

<!-- web.config -->
<add key="APG.Skin.MobilePath" value="/skins/Mobile" />
<!-- Verify this folder exists and contains skin files -->

Fix: Point to the Bundled Mobile Skin

<add key="APG.Skin.MobilePath"    value="/skins/DefaultMobile" />
<add key="APG.Skin.MobileEnabled" value="true" />
<add key="APG.Skin.MobileBreakpointPx" value="768" />

The bundled DefaultMobile skin is located in the APG vNext installation package under /skins/DefaultMobile/. If it's missing, re-extract it from the original installation archive.

Force Desktop Skin (Disable Mobile Theme)

If mobile skin switching is causing issues and you use a responsive desktop skin instead:

<add key="APG.Skin.MobileEnabled" value="false" />

Related Resources

Crash When Switching to Mobile Theme in APG vNext

A crash when switching to the mobile theme in APG vNext is typically caused by one of three issues: a missing or corrupted mobile theme file, a CSS or JavaScript error in the mobile theme that causes the browser to crash or become unresponsive, or a server-side exception during theme switching that results in a blank page or HTTP 500 error.

Diagnosing the Crash Type

// Open browser DevTools (F12) before switching to mobile theme:
// Console tab: watch for JavaScript errors during theme switch
// Network tab: watch for failed requests (red 4xx/5xx responses)

// If the crash is a blank page:
// Check APG vNext error log: Admin Panel → Tools → Error Log
SELECT TOP 10 ErrorDate, ErrorMessage, RequestUrl, UserAgent
FROM   apg_ErrorLog
WHERE  RequestUrl LIKE '%theme%' OR RequestUrl LIKE '%mobile%'
ORDER  BY ErrorDate DESC;

Fix: Reset to Default Theme

<!-- If you cannot access Admin Panel, reset theme in web.config: -->
<add key="APG.Skin.Default"       value="default" />
<add key="APG.Skin.Mobile"        value="default-mobile" />
<add key="APG.Skin.AutoDetect"    value="false" />
<!-- Disable auto-detection to prevent automatic mobile theme activation -->

Mobile Theme File Requirements

APG vNext requires specific files to be present for mobile theme switching to function:

Required mobile theme files:
/skins/[MobileThemeName]/
  ├── templates/
  │   ├── master.ascx         (master layout)
  │   ├── header.ascx         (mobile header)
  │   ├── footer.ascx         (mobile footer)
  │   └── thread-view.ascx    (thread view)
  ├── css/
  │   ├── mobile.css          (mobile-specific styles)
  │   └── variables.css       (CSS custom properties)
  └── skin.json               (theme metadata file — required in 5.x+)

Validating the skin.json File

{
  "name": "MyMobileTheme",
  "version": "1.0",
  "type": "mobile",           // Must be "mobile" for mobile themes
  "minAPGVersion": "5.0",
  "author": "Your Name",
  "description": "Mobile-optimised theme"
}

Browser Compatibility During Theme Switch

Mobile theme switching on APG vNext uses a JavaScript-driven approach that dynamically loads the mobile CSS and updates the DOM. In older browsers (IE11, early Chrome for Android), this dynamic approach can fail silently, leaving the page in a broken mixed-style state. APG vNext's server-side theme detection (via User-Agent) is more reliable for mobile users than client-side switching — configure it to detect mobile User-Agents and serve the mobile theme automatically without requiring a manual switch:

<add key="APG.Skin.AutoDetect"          value="true" />
<add key="APG.Skin.AutoDetect.MobileUA" value="iPhone|iPad|Android|Mobile" />

Testing Mobile Theme Switch in Isolation

When debugging a mobile theme crash, isolate the mobile theme switch from all other variables by creating a test member account and testing the switch in a private browser window. This eliminates browser extension conflicts, cached CSS/JS, and member-specific preference data as potential causes. If the crash only affects one member's account, the issue may be a corrupted theme preference stored in their member record, which can be reset via Admin Panel → Users → [Member] → Reset Preferences. If the crash affects all members, the issue is in the theme files themselves or a server-side exception triggered during theme detection, requiring a server-level investigation.

Related Resources


Looking for more help? Browse the support forum or check the Knowledge Base.