State Management System - ASP.NET Placement questions

State Management System - ASP.NET Placement questions


Q.1 Which object works on client side in state management system?

A) ViewState
B) cookies
C) Query strings
D) All of the above.

View Answer / Hide Answer

ANSWER: D




Q.2 What are the client-side state management options that ASP.NET supports?

A) Application
B) Session
C) Query strings
D) Option A and B are correct.

View Answer / Hide Answer

ANSWER: D




Q.3 Cookies can store which type of data?

A) String
B) DateTime
C) System.Int32
D) None of the above.

View Answer / Hide Answer

ANSWER: A

Explanation:

Cookies are small piece of information that server creates on the browser. You can store only string values when using a cookie.




Q.4 What are the types of cookies?

A) Session cookies
B) Persistent cookies.
C) Dummy cookies.
D) Option A and B are correct.

View Answer / Hide Answer

ANSWER: D

Explanation:

There are two types of cookies: session cookies and persistent cookies. A session cookie exists only in memory. If a user closes the web browser, the session cookie will be lost.
A persistent cookie, on the other hand, can remain for months or even years. When you create a persistent cookie, the cookie is stored permanently by the user’s browser on the user’s computer.




Q.5 What is/are the advantages of session state?

A) It helps to maintain user data to all over the application and can store any kind of object.
B) Stores every client data separately.
C) Session is secure and transparent from user.
D) All of the above

View Answer / Hide Answer

ANSWER: D




Q.6 In ASP.NET what are the different types of session mode available?

A) InProc
B) StateServer
C) SQLServer
D) All of the above

View Answer / Hide Answer

ANSWER: D

Explanation:
InPorc Session Mode:

This is the default session mode in Asp.Net. Its stores session Information in Current Application Domain. There are no requirements of serialization to store data in InProc Session Mode.
StateServer Session Mode:

This is also called Out-Proc session mode. It is managed by aspnet_state.exe. In this mode server may runs on the same system, but it's outside of that main application domain where your web site is running. It is useful in web farm and web garden scenarios.

SQL Server Session Mode:

In this session mode, the Session data is serialized and stored in the SQL Server database. We should use SQL server session mode when we need to implement Session with some more security.




Q.7 Which session modes stores session Information in Current Application Domain?

A) InProc
B) StateServer
C) SQLServer
D) Off

View Answer / Hide Answer

ANSWER: A

Explanation:

InProc session mode stores its session data in a memory object on that application domain. This is handled by worker process in application pool. So if you restart the server you will lose the session data. In web.config file you can mention Session mode and also you have to set the Timeout.
<system.web>
<sessionState mode=”InProc” timeout=”30”>
</system.web>




Q.8 In which session mode serialization is not required to store the data?

A) Off
B) InProc
C) StateServer
D) SQLServer

View Answer / Hide Answer

ANSWER: B




Q.9 What is/are the advantages of StateServer session mode?

A) Its keeps the data separate from IIS so; if any Issue comes with IIS it will not hamper Session data.
B) It is useful in web farm and web garden scenarios.
C) Process is fast due to serialization and de-serialization.
D) A and B are the correct option.

View Answer / Hide Answer

ANSWER: D




Q.10 Choose the correct option about writing and reading cookies.

A) // Writing cookies
Response.Cookies["WebSiteName"].Value = "CareerRide";
Response.Cookies["WebSiteName"].Expires = DateTime.Now.AddDays(1);
// Reading Cookies
if(Request.Cookies["WebSiteName"] != null)
Label1.Text = Server.HtmlEncode(Request.Cookies["WebSiteName"].Value);

B) // Writing cookies
HttpCookie CookieObj = new HttpCookie("lastVisit");
CookieObj.Value = DateTime.Now.ToString();
CookieObj.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(CookieObj);
// Reading Cookies
if(Request.Cookies["lastVisit"] != null)
{
HttpCookie obj = Request.Cookies["lastVisit"];
Label1.Text = Server.HtmlEncode(obj.Value);
}
C) Both of the above.
D) None of the above.

View Answer / Hide Answer

ANSWER: C




Q.11 Choose the correct option about storing Multiple Values in a Cookie.

A) Response.Cookies["visit"].Value = DateTime.Now.ToString();
Response.Cookie["WebsiteName"].Value = "CareerRide";
Response.Cookies["color"].Value = "blue";

B) Response.Cookies.Value = DateTime.Now.ToString();
Response.Cookies.Value = "CareerRide";
Response.Cookies.Value = "blue";

C) Response.Cookies["info"]["visit"].Value = DateTime.Now.ToString();
Response.Cookies["info"]["WebsiteName"].Value = "CareerRide";
Response.Cookies["info"]["color"].Value = "blue";
Response.Cookies["info"].Expires = DateTime.Now.AddDays(1);

D) None of the above.

View Answer / Hide Answer

ANSWER: C




Q.12 Which object data is included in bookmarks and e-mailed URLs?

A) ViewState
B) cookies
C) Query strings
D) All of the above.

View Answer / Hide Answer

ANSWER: C




Q.13 Which object in ASP.NET provides a global storage mechanism for state data that needs to be accessible to all pages in a given Web application?

A) Session
B) Application
C) ViewState
D) None of the above.

View Answer / Hide Answer

ANSWER: B




Q.14 In which file should you write code to respond to the Application_Start event?

A) Any ASP.NET web page with an .aspx extension
B) Web.config
C) Global.asax
D) None of the above.

View Answer / Hide Answer

ANSWER: C




Q.15 You need to log data to a database when a user’s session times out. Which event should you respond to?

A) Application_Start
B) Session_End
C) Session_Start
D) Application_End

View Answer / Hide Answer

ANSWER: B




Q.16 How will you store and retrieve value in viewstate?

A) // Storing the data in viewstate
ViewState[“SiteName”]=”CareerRide”;

// Retrieving Value from a View State
Label1.Text = ViewState["SiteName "].ToString();

B) // Storing the data in viewstate
ViewState obj=new ViewState
ViewState [obj]=”CareerRide”;

// Retrieving Value from a View State
Label1.Text = ViewState[obj].ToString();

C) // Storing the data in viewstate
ViewState=”CareerRide”;

// Retrieving Value from a View State
Label1.Text = ViewState.ToString();

D) None of the above.

View Answer / Hide Answer

ANSWER: A

Explanation:

View State stores data on client side. It can be used to maintain the State at a page level, it means that the information is being stored for a specific page until that page is active once the user is re-directed or goes to some other page, the information stored in the View State gets lost. You cannot retrieve the ViewState data to some other page.



Post your comment