Design the application architecture - Objective 1.4: Configure state management Flashcards
What 6 places can you store state information in an ASP.Net MVC application?
- Cache
- Session
- Cookies
- QueryString
- [Http]Context.Items
- Profile
What is the ASP.Net Cache?
A memory pool store on the server and shared across users
What is the ASP.Net Session?
A store on the server that is unique for each user
What are cookies?
Strings that are stored locally in the browser’s cache and are sent with each HTTP request to the server
What is the QueryString?
The part of the URL after the question mark
What is the HttpContext.Items?
A place to store data which is needed only for the lifetime of the request
What is ASP.Net profile?
User-specific information stored in a database which persists across multiple sessions
What is a major consideration of using ASP.Net Cache in a web farm?
Each server needs its own copy of the Cache since any individual request cannot be guaranteed to be sent to a specific server.
Which class must you inherit from to implement a custom session state provider in ASP.Net, for example, one that stores session in an Oracle database,?
SessionStateStoreProviderBase
How do you configure IIS to support a custom session state provider?
- Open IIS Manager and navigate to the web site.
- In Features View, double-click Session State.
- On the Session State page, in the Session State Mode Settings area, click Custom.
- Click Apply in the Actions pane.
What are cookies?
Small snippets of information stored on the client side that can persist across sessions and are individualized to a particular domain or subdomain.
When are cookies sent to and from a server?
They are sent to and from a server with every request and response.
In ASP.Net, which class is used to read incoming cookies on the server?
HttpContext.Request.Cookies
In ASP.Net, which class is used to write outgoing cookies on the server?
HttpContext.Response.Cookies
What is a query string?
Information passed as part of the URL. The query string part of the URL is any text after the question mark.
Ex:
Given this url - http://www.microsoft.com/?id=20
The query string is id=20.
In ASP.Net, which class is used to read the query string sent during a request?
HttpContext.Request.QueryString
Why should you not put personal or information that should be secure in the query string?
Query strings/URLs are not encrypted even over SSL.
Where is HttpContext.Items most commonly written to?
In HTTP modules, such as during the authentication phase of a request.
In ASP.Net, which class is used to read user profile information?
HttpContext.Profile
What must be configured in the web.config before ASP.Net user profiles can be used?
A membership and a profile provider
What is the maximum size cookies can be?
4 KB
What is one advantage of using cookies over HTML5 web storage for maintaining state?
With cookies, no additional code needs to be written since cookies are automatically sent/received during requests.
What two JavaScript objects are used to access HTML5 web storage?
sessionStorage and localStorage
What is the difference between HTML5 session storage and local storage?
Local storage persists after the browser closes. Session storage persists only while the window or tab is still open.
In ASP.Net, how do you determine the capabilities of the current user’s browser?
Access the HttpRequest.Browser property which returns an HttpBrowserCapabilities object.
In JavaScript, how do you determine if the browser supports HTML5 web storage?
Test the window object for the presence of the localStorage or sessionStorage properties.
Ex:
if (window.localStorage)
{
window.localStorage.setItem(“MyKey”, “MyValue”);
}
In JavaScript, how do you determine if HTML5 web storage has been updated?
Add an event listener for the storage event of the window object.
Ex:
window.addEventListener(“storage”, myEventHandler, true);