---
schema_version: "1"
id: 2604905bc1aa2c4755b58cf5cc5f769b0b6c7e43654c98bb39d56a883939603d
title: What are Custom Controllers and Controller Extensions?
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/salesforce-pages-developers-guide/guides/pages/controller/pages-controller-def.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-pages-developers-guide/guide/pages-controller-def.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 71e732cb5a8853c4af3835f9e86f2e8c3a9036f527ac0fb9b152a07fce6b9e18
products:
  - Visualforce Developer Guide
  - Platform Developer Content
---

# What are Custom Controllers and Controller Extensions?

A custom controller is an Apex class that implements all of the logic for a page without leveraging a standard controller. Use custom controllers when you want your Visualforce page to run entirely in system mode, which does not enforce the permissions and field-level security of the current user.

A controller extension is an Apex class that extends the functionality of a standard or custom controller. Use controller extensions when:

-   You want to leverage the built-in functionality of a standard controller but override one or more actions, such as edit, view, save, or delete.
-   You want to add new actions.
-   You want to build a Visualforce page that respects user permissions. Although a controller extension class executes in system mode, if a controller extension extends a standard controller, the logic from the standard controller does not execute in system mode. Instead, it executes in user mode, in which permissions, field-level security, and sharing rules of the current user apply.

**note:** Custom controllers and controller extension classes execute in system mode, so they ignore user permissions and field-level security. However, you can choose whether they respect a user's organization-wide defaults, role hierarchy, and sharing rules by using the `with sharing` keywords in the class definition. For information, see “Using the `with sharing`, `without sharing`, and `inherited sharing` Keywords” in the [Apex Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_keywords_sharing.htm).

