---
schema_version: "1"
id: c4ac6e12c5801d295e8f92dd209ab3c2633096a0311e3432642383954be15fc7
title: PageReference Methods
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_System_PageReference_methods.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_methods.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 023075c95e8de470974225d9da5cb5071ae442065bff85a931c4af33b814ba5c
---
# PageReference Methods

The following are methods for PageReference. All are instance methods.

- **[forResource(resourceName, path)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_forResource.htm)**  
    Create a PageReference for nested content inside a zip static resource, by name and path.
- **[forResource(resourceName)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_forResource_2.htm)**  
    Create a PageReference for a static resource, by name.
- **[getAnchor()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_getAnchor.htm)**  
    Returns the name of the anchor referenced in the page’s URL. That is, the part of the URL after the hashtag (#).
- **[getContent()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_getContent.htm)**  
    Returns the output of the page, as displayed to a user in a web browser.
- **[getContentAsPDF()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_getContentAsPDF.htm)**  
    Returns the page in PDF, regardless of the <apex:page\> component’s renderAs attribute.
- **[getCookies()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_getCookies.htm)**  
    Returns a map of cookie names and cookie objects, where the key is a String of the cookie name and the the value contains the cookie object with that name.
- **[getHeaders()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_getHeaders.htm)**  
    Returns a map of the request headers, where the key string contains the name of the header, and the value string contains the value of the header.
- **[getParameters()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_getParameters.htm)**  
    Returns a map of the query string parameters for the PageReference; both POST and GET parameters are included. The key string contains the name of the parameter, while the value string contains the value of the parameter.
- **[getRedirect()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_getRedirect.htm)**  
    Returns the current value of the PageReference object's redirect attribute.
- **[getRedirectCode()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_getRedirectCode.htm)**  
    Returns the HTTP redirect code used when [getRedirect()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_getRedirect.htm "Returns the current value of the PageReference object's redirect attribute.") is set to true for the PageReference object.
- **[getUrl()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_getUrl.htm)**  
    Returns the relative URL associated with the PageReference when it was originally defined, including any query string parameters and anchors.
- **[setAnchor(anchor)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_setAnchor.htm)**  
    Sets the URL’s anchor reference to the specified string.
- **[setCookies(cookies)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_setCookies.htm)**  
    Creates a list of cookie objects. Used in conjunction with the Cookie class.
- **[setRedirect(redirect)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_setRedirect.htm)**  
    Sets the value of the PageReference object's redirect attribute. If set to true, a redirect is performed through a client side redirect.
- **[setRedirectCode(redirectCode)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_setRedirectCode.htm)**  
    Sets the HTTP redirect code to use for the PageReference object when [setRedirect(redirect)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_System_PageReference_setRedirect.htm "Sets the value of the PageReference object's redirect attribute. If set to true, a redirect is performed through a client side redirect.") is set to true.