Developing ASP.NET MVC Web Applications — Question 170
You develop a new ASP.NET MVC application. You use local storage to maintain state.
The localStorage object's setItem method is failing to store a value.
Which two scenarios will cause the failure? Each correct answer presents a complete solution.
NOTE: Each correct selection is worth one point.
Answer options
- A. The user has disabled local storage in the browser.
- B. The value being stored is a JavaScript array.
- C. The new Value property was used prior to calling the setItem method.
- D. The value being stored exceeds 10MB in size.
Correct answer: B, C
Explanation
Option B is incorrect because JavaScript arrays can be converted to strings and stored in local storage. Option C is correct since attempting to use the new Value property before setItem would result in a failure. Option A is not valid because local storage being disabled would not relate to the specific use of the setItem method, while D is also not applicable as local storage does not have a strict 10MB limit in all browsers.