Print this page

Internal Server Error on VF page because View State limit exceeded

Knowledge Article Number 000176523
Description While executing a VF page you may see an Internal Server Error ID
Error message appears due to Maximum view state size limit hit that is 135 KB

Step 1: 
This will occurs when the variable is u declared as a public .So try to declare this variables as transient. Because this transient keyword used to declare instance variable that cannot be saved. 
Step 2: 
Open the view state and check which variable it taking the kilobytes, see if you can set that variable to null after rendering the page.
You have to enable view state from your personal information if it’s already not enabled. 
If you edit your profile, there are two checkboxes - "development mode" and "show view state in development mode". If you check both of these, you will have access to the view state inspector. However, if you are already exceeding the view state it may not be much help - you might need to reduce it before you can see it properly if you get my meaning. 
Step 3: 
You will be using a variable to hold file data like this. 
VF Page: 
<apex:inputFile value="{!file}"/> 
In Apex class: 
public blob file{get; set;} 
Use transient keyword before blob data type. like below, 
public transient blob file{get; set;} 
The transient keyword gives persistence in the VF page.. 

promote demote