Creating User Services

Posted on
Share on Google+Share on LinkedInShare on FacebookShare on RedditTweet about this on TwitterEmail this to someone

70-305 – Developing and Implementing Web Applications with Microsoft Visual Basic .NET and Microsoft Visual Studio .NET


Objective: Creating User Services
SubObjective: Use and edit intrinsic objects. Intrinsic objects include response, request, session, server and application.


Item Number: 70-305.1.13.1
Single Answer, Multiple Choice


Joan has a Web application developed in ASP.NET that allows the user to set many preferences for the user interface. Joan includes this code in the Page_Load event for her Web Form: (Line numbers are included only for reference.)


01    If Request.Cookies (“UserPreferences”) Is Nothing Then


02    Dim MyCookie As HttpCookie


03    MyCookie=New HttpCookie (“UserPreferences”)


04    MyCookie.Values.Add (“ForeColor”, “black”)


05    MyCookie.Values.Add (“FontSize”, “10pt”)




07 End If


After Joan added the code and tested the application, she expected a cookie to be deposited on the client’s browser, but she finds that this was not the case.


Which statement should be added at Line 06 to place the new cookie on the user’s computer?



  1. Request.AppendCookie (MyCookie)
  2. Response.Cookies.Add(MyCookie)
  3. Cookies (“UserPreferences”).Transfer
  4. Request.Cookies (“UserPreferences”).Append
  5. Response.Cookies (“UserPreferences”).Append


B. Response.Cookies.Add(MyCookie)


You should use the line of code that calls the Add method of the Response object’s Cookies collection. Cookies are files that store small amounts of volatile or non-volatile data on the users’ computers. This code checks to see if the user’s computer contains a cookie named “UserPreferences”. If it does not, a new one is created. A couple of preferences are set in the cookie, but the code is missing the line to write the cookie to the user’s computer. The new cookie was created with the variable name MyCookie. This variable name is passed to the Add method of the Response object’s Cookies collection, which is responsible for transferring the cookie to the client.


You should not use either of the lines of code that reference the Request.Cookies object. The Request.Cookies object transfers cookie information from the client to the server, not the other way around.


You should not add the line of code that calls Cookies.Transfer or Response.Cookies.Append. Nether of these is a valid object/property combination.


1. MSDN Library Visual Studio .NET – Search

– Visual Basic and Visual C# Concepts – State Management Concepts

Share on Google+Share on LinkedInShare on FacebookShare on RedditTweet about this on TwitterEmail this to someone


Posted in Archive|


Leave a comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>