OrchardCMS/OrchardCore · error · ArgumentOutOfRangeException

Invalid bulk options.

Error message

Invalid bulk options.

What it means

The Users AdminController Index POST action iterates selected users and applies the chosen BulkAction (e.g. Enable/Disable/Delete). If the submitted bulk action value falls outside the known enum cases, the default branch throws ArgumentOutOfRangeException with the message 'Invalid bulk options.', defending against tampered or outdated form posts.

Solutions

  1. Reload the Users admin page and retry with a valid bulk action (Enable/Disable/Delete) so the posted value matches the current enum.
  2. Inspect the POST payload (bulkAction field) and correct it to a supported value.
  3. If integrating programmatically, update the client to send valid enum values from the current OrchardCore.Users version.
  4. Clear cached admin pages/scripts after upgrading Orchard Core.

Example fix

// before (form post)
bulkAction=9
// after
bulkAction=1 // e.g. BulkAction.Enable
Defensive patterns

Strategy: validation

Validate before calling

// client-side: only submit whitelisted bulk actions
if (!['enable','disable','delete'].includes(bulkAction)) {
  alert('Choose a valid bulk action');
  return;
}

Type guard

const isBulkAction = (v) => ['Enable','Disable','Delete'].includes(v);

Try / catch

try {
  await ApplyBulkActionAsync(bulkAction, userIds);
} catch (ArgumentOutOfRangeException ex) when (ex.Message.Contains("Invalid bulk options")) {
  _notifier.Warning(H["Unsupported bulk action selected. Refresh the page and try again."]);
}

Prevention

When it happens

Trigger: Posting the user Index form with a bulkAction value that is not one of the supported enum values — e.g. hand-crafted/tampered POST, stale client page after a server enum change, or an automated client sending an out-of-range value.

Common situations: Browser extension or script altering the form; server upgraded with new/renamed bulk actions while an old cached admin page posts old values; API/script integration posting invalid bulkAction numbers.

Related errors


AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13). Data as JSON: /api/errors/e132ad0633e643c0. Report an issue: GitHub.

Appendix: source

Thrown at src/OrchardCore.Modules/OrchardCore.Users/Controllers/AdminController.cs:273

                            await _notifier.SuccessAsync(H["User {0} successfully deleted.", user.UserName]);
                        }
                        break;
                    case UsersBulkAction.Disable:
                        if (!isSameUser && canEditUser)
                        {
                            await _userService.DisableAsync(user);
                            await _notifier.SuccessAsync(H["User {0} successfully disabled.", user.UserName]);
                        }
                        break;
                    case UsersBulkAction.Enable:
                        if (!isSameUser && canEditUser)
                        {
                            await _userService.EnableAsync(user);
                            await _notifier.SuccessAsync(H["User {0} successfully enabled.", user.UserName]);
                        }
                        break;
                    default:
                        throw new ArgumentOutOfRangeException(options.BulkAction.ToString(), "Invalid bulk options.");
                }
            }
        }

        return RedirectToAction(nameof(Index));
    }

    public async Task<IActionResult> Create()
    {
        var user = new User();

        if (!await _authorizationService.AuthorizeAsync(User, UsersPermissions.EditUsers, user))
        {
            return Forbid();
        }

        var shape = await _userDisplayManager.BuildEditorAsync(user, updater: _updateModelAccessor.ModelUpdater, isNew: true, string.Empty, string.Empty);

View on GitHub (pinned to 4306c0717f)