70562 (1)

2,209 views
2,162 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,209
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

70562 (1)

  1. 1. Question 1 / 75 Mark for Review You create a Web application by using Microsoft ASP.NET 3.5. You are not using an exception management framework in the application. However, the application must automatically log all unhandled exceptions to the event log. You need to configure the Web.config file accordingly. Which configuration should you use? <healthMonitoring enabled="true"/> <deployment retail="true"/> <customErrors mode="On"/> <trace enabled="true"/>Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-051 Jump to Question IDQuestion 1 Explanation:You should set the enabled attribute of the healthMonitoring element to true. Thisenables health monitoring. Health monitoring defines events to be monitored, providersthat deliver the events, and rules that map events to providers. The root Web.config isconfigured to deliver all unhandled exceptions to the event log. However, it sets theenabled attribute to false, which is why you must set it to true in the applicationsWeb.config file.You should not configure the customErrors element. This element allows you to specifyhow the application displays unhandled exceptions.
  2. 2. You should not configure the trace element. This element allows you to enable andconfigure ASP.NET tracing.You should not configure the deployment element. This element only has meaning inthe machine.config file. When the retail attribute is set to true, features such as customerrors, ASP.NET tracing, and debugging are disabled.Objective:List allquestionsfor thisobjective</ Troubleshooting and DebuggingP< td>Web ApplicationsSub-Objective:4.6 Monitor Web applications.2. You create a Web site by using Microsoft ASP.NET 3.5. You create the following classin a separate code file:public static class ChartColors{public static Color NormalActivityColor = Color.Green;public static Color WarningActivityColor = Color.Yellow;public static Color ErrorActivityColor = Color.Red;public static Color GetRandomColor(){Random random = new Random((int)DateTime.Now.Ticks);int randomArgbValue = random.Next();Color color = Color.FromArgb(255, Color.FromArgb(randomArgbValue));return color;}}You need to configure the Web site project so that this class can be consumed by theWeb site.
  3. 3. What should you do? Add the file to the App_Code folder of the project. Add a Register directive that references the file to each page that consumes the class. Reference the file in the assemblies section of the Web.config file. Reference the file in the httpHandlers section of the Web.config file.Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-004 Jump to Question IDQuestion 2 Explanation:You should add the file to the App_Code folder of the project. The App_Code folderallows you to store utility classes for users in a Web site project. Code placed in thisfolder is dynamically compiled into an assembly.You should not reference the file in the assemblies section of the Web.config file. Youshould reference binary assemblies in the assemblies section. In this scenario, the codefile is not a binary assembly because the code is not yet compiled.You should not add a Register directive that references the file to each page thatconsumes the class. You should use the Register directive to reference files containinguser controls or assemblies containing server controls.You should not reference the file in the httpHandlers section of the Web.config file. Youshould use the httpHandlers section to reference classes that implement theIHttpHandler interface. In this scenario, the ChartColors class does not implement aninterface.
  4. 4. Objective:List allquestionsfor thisobjective</ Programming Web ApplicationsP< td>Sub-Objective:7.4 Implement business objects and utility classes.References:Question 3 / 75 Mark for Review You create a Web application by using Microsoft ASP.NET 3.5. The following code exists in the code-behind file for a page: private void Process(Location[] locations) { if (_scriptManager.IsInAsyncPostBack) { JavaScriptSerializer jsonSerializer = new JavaScriptSerializer(); string jsonArray = jsonSerializer.Serialize(locations); _scriptManager.RegisterDataItem(_locationGridView, jsonArray, true); } } This code creates a JavaScript Object Notation (JSON) array from an array of Location instances. The _locationGridView control is contained within four nested naming containers on the page. You need to access the JSON array from client script. Which code segment should you use?
  5. 5. Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(OnL oaded); function OnLoaded(sender, args) { var dataItems = args.get_dataItems(); var locations = dataItems[<%= _locationGridView.ClientID %>]; } Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(OnRequest); function OnRequest(sender, args) { var dataItems = args.get_postBackElement(); var locations = dataItems[_locationGridView]; } Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(OnLoading); function OnLoading(sender, args) { var dataItems = args.get_dataItems(); var locations = dataItems[_locationGridView]; } Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(OnInit); function OnInit(sender, args) { var dataItems = args.get_postBackElement(); var locations = dataItems[<%= _locationGridView.ClientID %>]; }Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-019 Jump to Question IDQuestion 3 Explanation:You should use the following code segment:Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(OnLoaded);function OnLoaded(sender, args){var dataItems = args.get_dataItems();var locations = dataItems[<%= _locationGridView.ClientID %>];}This code creates an event handler for the pageLoaded Asynchronous JavaScript andXML (AJAX) event. This event is raised after an AJAX request is completed and page
  6. 6. regions are updated. The event handler defines a PageLoadedEventArgs parameter thatrepresents the event arguments. The PageLoadedEventArgs object contains a propertynamed dataItems that contains all data items registered by the call to theRegisterDataItem method of the ScriptManager class. The data items are indexed bythe client IDs of the controls that were specified in the call to the RegisterDataItemmethod. In this scenario, the code passed the _locationGridView control instance to theRegisterDataItem method to register a JSON array as a data item. To access this array,you must use the client ID of the _locationGridView control instance. Because the_locationGridView control is contained with four nested naming containers, this codeuses the <%= _locationGridView.ClientID %> syntax to obtain the client ID of the_locationGridView control. When a control is contained within nested namingcontainers, its client ID is prefixed with the names of the naming containers.You should not use the following code segment:Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(OnRequest);function OnRequest(sender, args){var dataItems = args.get_postBackElement();var locations = dataItems[_locationGridView];}This code creates an event handler for the beginRequest AJAX event. This event israised after an AJAX request is initiated but before the request is sent to the server.Items registered by using the RegisterDataItem method of the ScriptManager class canonly be accessed in pageLoaded, pageLoading and endRequest events ofPageRequestManager.You should not use the following code segment:Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(OnInit);function OnInit(sender, args){var dataItems = args.get_postBackElement();var locations = dataItems[<%= _locationGridView.ClientID %>];}This code creates an event handler for the initializeRequest AJAX event. This event israised before an AJAX request is initialized. Items registered by using theRegisterDataItem method of the ScriptManager class can only be accessed inpageLoaded, pageLoading and endRequest events of PageRequestManager.You should not use the following code segment:
  7. 7. Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(OnLoading);function OnLoading(sender, args){var dataItems = args.get_dataItems();var locations = dataItems[_locationGridView];}This code creates an event handler for the pageLoading AJAX event. This event is raisedafter an AJAX request has completed but before page regions are updated. You canaccess registered data items from this event handler. However, this code uses the string"_locationGridView" to index the data items. According to the scenario, the_locationGridView control is contained within four nested naming containers on thepage. This means that its client ID is prefixed with the names of the naming containers.Objective:List allquestionsfor thisobjective</ Working with ASP.NET AJAX andP< td>Client-Side ScriptingSub-Objective:5.2 Interact with the ASP.NET AJAX client-side library.References: 1. ScriptManager.RegisterDataItem Method (Control, String, Boolean) Click here for further information MSDN, Microsoft 2. Sys.WebForms.PageRequestManager pageLoaded Event Click here for further information MSDN, Microsoft 3. Sys.WebForms.PageLoadedEventArgs Class Click here for further information MSDN, Microsoft
  8. 8. 4. An Introduction to JavaScript Object Notation (JSON) in JavaScript and .NET Click here for further information MSDN, MicrosoftQuestion 4 / 75 Mark for Review You create a Web application by using Microsoft ASP.NET 3.5. The following markup exists on a page: <asp:TextBox ID="_titleTextBox" runat="server"/> <asp:Button ID="_button" runat="server" Text="Filter"/> <asp:SqlDataSource ID="_bookDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:Publishing %>" SelectCommand="GetBooks" SelectCommandType="StoredProcedure" FilterExpression="Active=1 AND Title LIKE {0}%"> <FilterParameters> <asp:ControlParameter ControlID="_titleTextBox"/> </FilterParameters> </asp:SqlDataSource> <asp:GridView ID="_bookGridView" runat="server" DataSourceID="_bookDataSource"/> The page retrieves all books in the companys database and displays only the active books. The TextBox control allows you to also filter books by title. When you click the Filter button and do not specify a title, the page does not filter by active books. It displays all books retrieved from the database. If you do not specify a title, you want the page to display only active books. You need to solve this problem. What should you do? Set the Name property of the ControlParameter control. Set the PropertyName property of the ControlParameter control to Text. Set the ControlParameter controls ConvertEmptyStringToNull property to false.
  9. 9. Replace the {0} placeholder in the FilterExpression property with the (?) symbol.Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-064 Jump to Question IDQuestion 4 Explanation:You should set the ControlParameter controls ConvertEmptyStringToNull property tofalse. When using FilterExpression and FilterParameters, if one of the evaluated valuesfor the FilterParameters collection is null, then the data will not get filtered at all. Toaccommodate this, you should set the ConvertEmptyStringToNull property to false. Thedefault value of this property is true. This means that if you do not specify a title, theparameter converts the empty string returned by the Text property of the TextBoxcontrol to null. Setting the value to false will cause the empty string to be passed to thedata source.You should not replace the {0} placeholder with the (?) symbol. You must use formatplaceholders in the FilterExpression property. The value of each parameter in theFilterParameters collection will replace the format placeholders in the FilterExpressionproperty when the data is filtered.You should not set the Name property of the ControlParameter control to solve thisproblem. You must set the Name property when using select parameters, insertparameters, update parameters, or delete parameters when executing SQL commandsthat use named parameters, such as @param1.You should not set the PropertyName property of the ControlParemeter control to Textto solve this problem. If you do not set the PropertyName property, theControlParameter control determines whether the ControlValueProperty attribute isapplied to the control specified by the ControlID property. If so, the ControlParameterproperty uses this attribute to obtain the value of the associated control. TheControlValueProperty attribute applied to the TextBox class specifies Text as the defaultproperty for ControlParameter controls.
  10. 10. Objective:List allquestionsfor thisobjective</ Working with Data and ServicesP< td>Sub-Objective:3.4 Implement a DataSource control.References: 1. SqlDataSource Web Server Control Declarative Syntax Click here for further information MSDN, Microsoft 2. Handling Null Database Values Using Data Source Controls Click here for further information MSDN, Microsoft 3. Filtering Data Using Data Source Controls Click here for further information MSDN, MicrosoftQuestion 5 / 75 Mark for Review You create a Web application by using Microsoft ASP.NET 3.5. The following HTML element exists on an ASP.NET page: <input type="hidden" name="HiddenField"/> You need to retrieve the value of the element in the code-behind class. Which code segment should you use? (Each correct answer presents a
  11. 11. complete solution. Choose two.) string value = Application["HiddenField"]; string value = ((HtmlInputHidden)Page.FindControl("HiddenField")).Value; string value = Request.Params["HiddenField"]; string value = Request.Form["HiddenField"]; string value = Context["HiddenField"];Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-006 Jump to Question IDQuestion 5 Explanation:You should access the HiddenField item from the Request.Form collection. Thiscollection contains all HTML form fields that are rendered by the page. This includesHTML Input elements.Alternatively, you can access the HiddenField item of the Request.Params collection.This collection contains HTML form fields, query string paramers, HTTP server variables,and cookies.You should not access items of the current HttpApplicationState instance. AnHttpApplicationState instance is created for each instance of an ASP.NET application.However, HTML form fields are not automatically stored in HttpContext instances.You should not access items of the current HttpContext instance. An HttpContextinstance is created during each HTTP request to an application. However, HTML formfields are not automatically stored in HttpContext instances.You should not call the FindControl method of the Page class to retrieve the HTML Inputelement. The FindControl method finds server controls only. In this scenario, the HTMLInput element is not a server control because it is missing the runat=server attribute.
  12. 12. Objective:List allquestionsfor thisobjective</ Programming Web ApplicationsP< td>Sub-Objective:7.2 Work with ASP.NET intrinsic objects.References: 1. HttpRequest.Form Property Click here for further information MSDN, Microsoft 2. HttpRequest.Params Property Click here for further information MSDN, Microsoft 3. ASP.NET Intrinsic Objects Click here for further information MSDN, MicrosoftQuestion 6 / 75 Mark for Review You create a Web application by using Microsoft ASP.NET 3.5. An Extensible Markup Language (XML) Web service is defined as follows: [WebService] public class PhoneService : WebService { [WebMethod] public string[] GetAvailableNumbers()
  13. 13. { // Omitted for brevity } } You use Microsoft Visual Studio 2008 to add a Web reference named TelephoneServices to the applications project. You need to call the GetAvailableNumbers Web method from a page. Which code segment should you use? WebService baseService = new WebService(); TelephoneServices.PhoneService service = baseService.GetService(typeof(TelephoneServices.PhoneService)); string[] numbers = service.GetAvailableNumbers(); TelephoneServices.PhoneService service = new TelephoneServices.PhoneService(); string[] numbers = service.GetAvailableNumbers(); ChannelFactory<PhoneService> factory = new ChannelFactory<PhoneService>(); PhoneService service = factory.CreateChannel(); string[] numbers = service.GetAvailableNumbers(); ChannelFactory<WebService> factory = new ChannelFactory<WebService>(); PhoneService service = (PhoneService)factory.CreateChannel(); string[] numbers = service.GetAvailableNumbers();Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-020 Jump to Question IDQuestion 6 Explanation:You should create an instance of the TelephoneServices.PhoneService proxy class andcall its GetAvailableNumbers method. When you use Visual Studio to add a Webreference to a Web service, Visual Studio generates a proxy class that contains thesame methods as the Web service. Calls made to the proxy methods are marshaled andsent to the corresponding Web methods.You should not use the ChannelFactory generic type to create a channel from thePhoneService proxy class. The type of channel you create must implementIOutputChannel or IRequestChannel. Web service proxy classes generated by VisualStudio do not implement either of these interfaces.
  14. 14. You should not call the GetService method of the WebService class to create aPhoneService proxy instance. You must create the proxy instance by calling thePhoneService proxy class constructor.You should not use the ChannelFactory generic type to create a channel from theWebService class. The type of channel you create must implement IOutputChannel orIRequestChannel. The WebService class does not implement either of these interfaces.Objective:List allquestionsfor thisobjective</ Working with Data and ServicesP< td>Sub-Objective:3.3 Call a Windows Communication Foundation (WCF) service or a Web service from anASP.NET Web page.References: 1. How to: Access a Web Service in Managed Code Click here for further information MSDN, Microsoft 2. How to: Add a Web Service to an Existing Web Project in Managed Code Click here for further information MSDN, Microsoft 3. How to: Call a Web Service Click here for further information MSDN, Microsoft
  15. 15. Question 7 / 75 Mark for Review You create a Web site by using Microsoft ASP.NET 3.5. The following code exists in the App_Code folder: public class ObjectParameter : Parameter { public string ObjectTypeName {get; set; } public string PropertyName {get; set; } protected override object Evaluate(HttpContext context, Control control) { if (String.IsNullOrEmpty(ObjectTypeName)) { throw new InvalidOperationException("ObjectTypeName is not set"); } if (String.IsNullOrEmpty(PropertyName)) { throw new InvalidOperationException("PropertyName is not set"); } Type type = System.Type.GetType(ObjectTypeName); BindingFlags flags = BindingFlags.Public | BindingFlags.Static | BindingFlags.GetProperty; object value = type.InvokeMember(flags, null, null, null); return value; } } public static class Security { public static string UserID { get { return Session["UserID"]; } } } The following stored procedure exists in a Microsoft SQL Server 2008 database: CREATE PROCEDURE GetStoresByUser @UserID INT AS SELECT StoreID, StoreName FROM Store where UserID=@UserID The connection string to the database is stored in the connectionStrings section and has the name SupplyChain. You need to use a data source control to call this stored procedure and pass the Security.UserID value to it as a parameter.
  16. 16. Which declaration should you use? <SqlDataSource ID="_dataSource" runat="server" ConnectionString="<%$ ConnectionStrings:SupplyChain%>" SelectCommand="GetStoresByUser" SelectCommandType="Text"> <SelectParameters> <cust:ObjectParameter Name="Security.UserID"/> </SqlDataSource> <ObjectDataSource ID="_dataSource" runat="server" DataObjectTypeName="<%$ ConnectionStrings:SupplyChain%>" TypeName="StoredProcedure" SelectMethod="GetStoresByUser"> <SelectParameters> <cust:ObjectParameter Name="UserID" ObjectTypeName="Security" PropertyName="UserID"/> </SelectParameters> </ObjectDataSource> <SqlDataSource ID="_dataSource" runat="server" ConnectionString="<%$ ConnectionStrings:SupplyChain%>" SelectCommand="GetStoresByUser" SelectCommandType="StoredProcedure"> <SelectParameters> <cust:ObjectParameter Name="UserID" ObjectTypeName="Security" PropertyName="UserID"/> </SelectParameters> </SqlDataSource> <ObjectDataSource ID="_dataSource" runat="server" DataObjectTypeName="StoredProcedure" TypeName="ConnectionStrings.SupplyChain" SelectMethod="GetStoresByUser"> <SelectParameters> <cust:ObjectParameter Name="Security.UserID"/> </SelectParameters> </ObjectDataSource>Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-016 Jump to Question IDQuestion 7 Explanation:
  17. 17. You should use the following declaration:<SqlDataSource ID="_dataSource" runat="server"ConnectionString="<%$ ConnectionStrings:SupplyChain%>"SelectCommand="GetStoresByUser"SelectCommandType="StoredProcedure"><SelectParameters><cust:ObjectParameterName="UserID"ObjectTypeName="Security"PropertyName="UserID"/></SelectParameters></SqlDataSource>This declares a SqlDataSource control that connects to the database. TheSelectCommand property specifies the SQL command or stored procedure to execute.In this scenario, the SelectCommandType property is set to StoredProcedure, so thevalue specified in the SelectCommand property is a stored procedure. TheSelectParameters property defines the parameters to pass to the stored procedure. Inthis scenario, the stored procedure accepts a single String parameter. To pass the valueof Security.UserID as a parameter, you should use the ObjectParameter class and set itsproperties appropriately. The ObjectTypeName property specifies the name of the class,and the PropertyName property specifies the property of that class. In this scenario, thename of the class is Security, and the name of the property of that class is UserID.You should not use the ObjectDataSource control. This control allows you to bind tobusiness or data objects. The TypeName property of this control should specify thecommon language runtime (CLR) type of the object to query. The SelectMethodproperty should specify a method of that type that is used to query data. TheDataObjectTypeName property should specify a CLR type that can be used for aparameter in an insert, update, or delete operation.You should not use the following declaration:<SqlDataSource ID="_dataSource" runat="server"ConnectionString="<%$ ConnectionStrings:SupplyChain%>"SelectCommand="GetStoresByUser"SelectCommandType="Text"><SelectParameters><cust:ObjectParameter Name="Security.UserID"/></SqlDataSource>This code sets the SelectCommandType property to Text, which indicates that the
  18. 18. SelectCommand property value is a SQL statement. Also, the ObjectParameter propertydoes not set the ObjectTypeName and PropertyName properties, but instead sets theName property to Security.UserID. You must set the Name property to the name of aparameter expected by the stored procedure. Also, in this scenario, if you do not set theObjectTypeName and PropertyName properties, the ObjectParameter class throws anexception.Objective:List allquestionsfor thisobjective</ Working with Data and ServicesP< td>Sub-Objective:3.4 Implement a DataSource control.References: 1. Parameter Class Click here for further information MSDN, Microsoft 2. Using Parameters with the SqlDataSource Control Click here for further information MSDN, MicrosoftQuestion 8 / 75 Mark for Review You create a Web application by using Microsoft ASP.NET 3.5. The application is hosted on a Web farm, and it uses in-process session state. It is not guaranteed that a user will remain connected to the same Web server across multiple requests.
  19. 19. A Web page contains the following code (line numbers are included for reference only): 01 protected void Page_Load(object sender, EventArgs e) 02 { 03 String connStr = WebConfigurationManager.ConnectionStrings[0].ConnectionString; 04 using (SqlConnection conn = new SqlConnection(connStr)) 05 { 06 SqlCommand cmd = new SqlCommand("GetExams", conn); 07 SqlDataAdapter adapter = new SqlDataAdapter(cmd); 08 DataSet ds = new DataSet(); 09 adapter.Fill(ds); 10 11 if (Request.QueryString["Process"] == Boolean.TrueString) 12 { 13 14 } 15 } 16 } This code fills a DataSet instance with exam information from a Microsoft SQL Server database. If a query string parameter named Process has the value True, you need to have a page named ExamProcesser.aspx access the data in the DataSet instance. You need to add code at line 13 to accomplish your goal. Which code segment should you use? Session["ExamInfo"] = ds; HttpWebRequest.Create("ExamProcesser.aspx").GetResponse(); Context.Items.Add("ExamInfo", ds); Response.Redirect("ExamProcesser.aspx"); Session["ExamInfo"] = ds; Response.RedirectLocation = "ExamProcesser.aspx"; Context.Items.Add("ExamInfo", ds); Server.Transfer("ExamProcesser.aspx");Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-002 Jump to Question IDQuestion 8 Explanation:
  20. 20. You should store the DataSet instance in the current HttpContext instance and call theTransfer method of the HttpServerUtility class. The Transfer method transfers thecurrent request to another page or HTTP handler without having the browser perform aredirect. An HttpContext instance gets created with each request to the application.This means that any data currently stored in the current HttpContext instance will beavailable after the transfer.You should not call the Redirect method of the HttpResponse class. This method sendsan HTTP response to the browser that instructs the browser to request the specifiedpage. Because the application is hosted on a Web farm, a user might be redirected toanother server with the request. If this happens, the DataSet instance stored in thecurrent HttpContext instance will get removed.You should not store the DataSet instance in the users HttpSessionState instance andcall the GetResponse method of an HttpWebRequest instance. The GetResponse methodof the HttpWebRequest instance sends an HTTP request to a Web server. In thisscenario, the Web server to which the user is currently connected will initiate therequest. This means the session associated with that request will be different from theone associated with the user.You should not store the DataSet instance in the users HttpSessionState instance andset the RedirectLocation property of the HttpResponse class. The RedirectLocationproperty instructs the browser to request the page indicated by the specified URL. Theapplication uses in-process session state, which means that a users session is notshared across multiple Web servers. Because the application is hosted on a Web farm, auser might be redirected to another server.Objective:List allquestionsfor thisobjective</ Programming Web ApplicationsP< td>Sub-Objective:7.6 Handle events and control page flow.References: 1. Server.Transfer Method
  21. 21. Click here for further information MSDN, Microsoft 2. How to: Redirect Users to Another Page Click here for further information MSDN, MicrosoftQuestion 9 / 75 Mark for Review You create a Web application by using Microsoft ASP.NET 3.5. You create a page named GenericError.aspx that displays a message to the user when an unhandled exception occurs. Most users access the application at http://www.bcdtrain.com/Crm. If the user accesses the application at http://127.0.0.1/Crm, the application must display an automatically generated page containing the stack trace when an unhandled exception occurs. You need to configure the Web.config file accordingly. Which configuration should you use? <customErrors mode="Off"> <error statusCode="500" redirect="GenericError.aspx"> </customErrors> <customErrors mode="RemoteOnly" defaultRedirect="GenericError.aspx"> </customErrors> <customErrors mode="On"> <error statusCode="500" redirect="GenericError.aspx"> </customErrors> <customErrors mode="Off" defaultRedirect="GenericError.aspx"> </customErrors>Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET Application
  22. 22. Development (C#) (Preview)Question ID: jehMS_70-562CS-043 Jump to Question IDQuestion 9 Explanation:You should configure the customErrors element to indicate how the application displaysunhandled exceptions. You should set the defaultRedirect attribute to GenericError.aspx.This attribute specifies the default URL to which the application will redirect when anunhandled exception occurs. You should set the mode attribute to RemoteOnly. Thisattribute specifies that only unhandled exceptions from remote users will cause theapplication to redirect to GenericError.aspx. In the context of custom errors, local usersare those who access the application at http://127.0.0.1/Crm. All other users areconsidered remote users. When the mode attribute is set to RemoteOnly, local userssee an automatically generated page containing the stack trace when unhandledexceptions occur.You should not set the mode attribute to On. This specifies that the application shouldnever display the automatically generated page containing the stack trace whenunhandled exceptions occur.You should not set the mode attribute to Off. This specifies that the application shouldalways display the automatically generated page containing the stack trace whenunhandled exceptions occur.Objective:List allquestionsfor thisobjective</ Troubleshooting and DebuggingP< td>Web ApplicationsSub-Objective:4.1 Configure debugging and custom errors.References: 1. customErrors Element (ASP.NET Settings Schema) Click here for further information MSDN, Microsoft
  23. 23. 2. Rich Custom Error Handling with ASP.NET Click here for further information MSDN, MicrosoftQuestion 10 / 75 Mark for Review You create a Web application by using Microsoft ASP.NET 3.5. You add a the following code to a generic handler file named ValidationHandler.ashx (line numbers are included for reference only): 01 public class ValidationHandler : IHttpHandler 02 { 03 public void ProcessRequest(HttpContext context) 04 { 05 Bitmap validationBitmap = (Bitmap)Session["ValidationImage"]; 06 07 } 08 public bool IsReusable 09 { 10 get 11 { 12 return false; 13 } 14 } 15 } You need to render the validationBitmap instance as a JPEG image when the ValidationHandler.ashx is requested. Which code segment should you add at line 06? context.Response.ContentType = "image/jpeg"; context.Response.Write(validationBitmap); context.Response.ContentType = "image/jpeg"; validationBitmap.Save(context.Request.InputStream, ImageFormat.Jpeg); context.Response.ContentType = "image/jpeg"; context.Response.Write(validationBitmap.RawFormat); context.Response.ContentType = "image/jpeg";
  24. 24. validationBitmap.Save(context.Response.OutputStream, ImageFormat.Jpeg);Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-001 Jump to Question IDQuestion 10 Explanation:You should set the Response.ContentType property of the context instance toimage/jpeg, and you should call the Save method of the validationBitmap instance. TheContentType property specifies the type of content that is rendered by the generichandler. By setting the value of the property to image/jpeg, you specify that a JPEGimage is rendered. The Save method of the Bitmap class allows you to save an image toa file or Stream instance. The Response.OutputStream property of the HttpContextclass represents the output stream of the HTTP response. You should use this stream torender the image to the browser. You can accomplish this by passing thecontext.Response.OutputStream instance as the first parameter to the Save method.The second parameter of the Save method specifies the format in which to save theimage.You should not pass the context.Request.InputStream instance as the first parameter tothe Save method. This instance represents the input stream of the HTTP request.You should not pass the validationBitmap instance as the parameter to the Writemethod of the context.Response instance. This would call the ToString method of thevalidationBitmap instance, which does not render the image to the browser.You should not pass the validationBitmap.RawFormat instance as the parameter to theWrite method of the context.Response instance. This would call the ToString method ofthe validationBitmap.ImageFormat instance, which does not render the image to thebrowser.Objective:List allquestionsfor thisobjective</ Programming Web ApplicationsP< td>
  25. 25. Sub-Objective:7.7 Implement the Generic Handler.References: 1. Introduction to HTTP Handlers Click here for further information MSDN, Microsoft 2. ASP.NET: Create Snazzy Web Charts and Graphics on the Fly with the .NET Framework Click here for further information MSDN, MicrosoftQuestion 11 / 75 Mark for Review You create a Web application by using Microsoft ASP.NET 3.5. The application uses diagnostic tracing to log unhandled exceptions. A page contains the following markup: <asp:ScriptManager ID="_scriptManager" runat="server"/> <asp:UpdatePanel ID="_udpatePanel" runat="server"> <asp:Button ID="_button" runat="server" Text="Process"/> </asp:UpdatePanel> When you click the Button control an unhandled exception occurs. However, the exception does not get logged. You need to configure the application so that the unhandled exception produced by clicking the Button control gets logged. What should you do? Handle the Error event of the Page class. Call the Write method of the System.Diagnostics.Trace class to log the exception. Handle the pageLoaded event of the PageRequestManager client object. Call the trace function of the Sys.Debug client object to log the exception.
  26. 26. Handle the endRequest event of the PageRequestManager client object. Call the trace function of the Sys.Debug client object to log the exception. Handle the AsyncPostBackError event of the ScriptManager control. Call the Write method of the System.Diagnostics.Trace class to log the exception.Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-047 Jump to Question IDQuestion 11 Explanation:You should handle the AsyncPostBackError event of the ScriptManager control and callthe Write method of the System.Diagnostics.Trace class to log the exception. TheAsyncPostBackError event is raised whenever an unhandled exception occurs during anasynchronous post back. Because the Button control is a child of the UpdatePanelcontrol, the Button control performs an asynchronous post back by default when it isclicked. The System.Diagnostics.Trace class allows you to write diagnostic tracemessages.You should not handle the Error event of the Page class. This event is raised whenunhandled exceptions occur during synchronous post backs, not asynchronous postbacks.You should not handle the endRequest event of the PageRequestManager client objectand call the trace function of the Sys.Debug client object. The endRequest event israised on the client when an asynchronous request ends. The Sys.Debug.trace functionwrites messages to a TextArea element that has an ID of TraceConsole. It does notimplement diagnostic tracing.You should not handle the pageLoaded event of the PageRequestManager client objectand call the trace function of the Sys.Debug client object. The pageLoaded event israised on the client after an asynchronous request ends and UpdatePanel controlregions are updated. The Sys.Debug.trace function writes messages to a TextAreaelement that has an ID of TraceConsole. It does not implement diagnostic tracing.
  27. 27. Objective:List allquestionsfor thisobjective</ Troubleshooting and DebuggingP< td>Web ApplicationsSub-Objective:4.3 Debug unhandled exceptions when using ASP.NET AJAX.References: 1. Debugging and Tracing AJAX Applications Overview Click here for further information MSDN, Microsoft 2. ScriptManager.AsyncPostBackErrorMessage Property Click here for further information MSDN, Microsoft 3. Customizing Error Handling for ASP.NET UpdatePanel Controls Click here for further information MSDN, Microsoft 4. ScriptManager Control Overview Click here for further information MSDN, Microsoft 5. Trace Class Click here for further information MSDN, Microsoft
  28. 28. Question 12 / 75 Mark for Review You create a Web application by using Microsoft ASP.NET 3.5. The following Asynchronous JavaScript and XML (AJAX)-enabled Windows Communication Foundation (WFC) service exists in an ASP.NET Web application: namespace BcdTrain.Information.Services { [ServiceContract(Namespace="BcdTrain.Services")] public class SearchService { [OperationContract] public string LookupPhoneNumber(string phoneNumber) { // Code omitted for brevity } } } You add the ScriptManager control to a page and reference the service. You also add a TextBox control named _phoneNumberTextBox. You need to call the LookupPhoneNumber method, passing to it the text displayed in the TextBox control. You must also display the return value of the method in a browser alert window. The naming container of the TextBox control is the page. You need to write the appropriate JavaScript code to call the LookupPhoneNumber method. Which code segment should you use? var phoneNumber = $get("_phoneNumberTextBox").value; BcdTrain.Information.Services.SearchService.LookupPhoneNumber(phoneNumber) ; window.alert($get("ReturnValue").value); var phoneNumber = $get("_phoneNumberTextBox").value; var result = BcdTrain. Services.SearchService.LookupPhoneNumber(phoneNumber); window.alert(result); var phoneNumber = $get("_phoneNumberTextBox").value; BcdTrain.Services.SearchService.LookupPhoneNumber(phoneNumber, OnSuccess); function OnSuccess() { window.alert($get("ReturnValue").value); }
  29. 29. var phoneNumber = $get("_phoneNumberTextBox").value; BcdTrain.Services.SearchService.LookupPhoneNumber(phoneNumber, OnSuccess); function OnSuccess(result) { window.alert(result); }Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-015 Jump to Question IDQuestion 12 Explanation:You should use the following JavaScript code segment:var phoneNumber = $get("_phoneNumberTextBox").value;BcdTrain.Services.SearchService.LookupPhoneNumber(phoneNumber, OnSuccess);function OnSuccess(result){window.alert(result);}The first line of code retrieves the value of the TextBox control, which will be passed tothe LookupPhoneNumber method of SearchService. The second line of code makes acall to the method. When calling AJAX-enabled Web services from JavaScript, you mustspecify the service contracts XML namespace as the JavaScript namespace. The reasonis because ASP.NET AJAX creates a JavaScript Object Notation (JSON) class that is partof a namespace that uses the same name as the service contracts XML namespace.Because the default XML namespace is always http://tempura.org, this allows ASP.NETAJAX to register a namespace even if a service contract is not part of a .NETnamespace. The first parameters to the JSON function match the first parameters to the.NET method. In addition, the JSON function accepts another parameter that specifiesanother JavaScript function to call after the service method returns. This functionaccepts a single parameter that specifies the return value of the service method call.You should not use the following JavaScript code segment:var phoneNumber = $get("_phoneNumberTextBox").value;BcdTrain.Information.Services.SearchService.LookupPhoneNumber(phoneNumber);
  30. 30. window.alert($get("ReturnValue").value);This code uses the .NET namespace instead of the service contracts namespace, whichwas used to register the JSON namespace. Also, this code does not specify a secondparameter to identify the JavaScript function to call after the service method returns.You should not use $get to access the return value. The $get function retrievesDocument Object Model (DOM) elements in a browser-independent way.You should not use the following JavaScript code segment:var phoneNumber = $get("_phoneNumberTextBox").value;BcdTrain.Services.SearchService.LookupPhoneNumber(phoneNumber, OnSuccess);function OnSuccess(){window.alert($get("ReturnValue").value);}This code does not declare the OnSuccess function correctly. The function must accept asingle parameter that specifies the return value of the service method call. The $getfunction retrieves DOM elements in a browser-independent way.You should not use the following JavaScript code segment:var phoneNumber = $get("_phoneNumberTextBox").value;var result = BcdTrain. Services.SearchService.LookupPhoneNumber(phoneNumber);window.alert(result);The LookupPhoneNumber JSON function does not return a value. You must specifyanother JavaScript function to retrieve the return value of the service method call.Objective:List allquestionsfor thisobjective</ Working with ASP.NET AJAX andP< td>Client-Side ScriptingSub-Objective:
  31. 31. 5.3 Consume services from client scripts.References: 1. Exposing WCF Services to Client Script Click here for further information MSDN, Microsoft 2. Calling Web Services from Client Script Click here for further information MSDN, Microsoft 3. An Introduction to JavaScript Object Notation (JSON) in JavaScript and .NET Click here for further information MSDN, MicrosoftQuestion 13 / 75 Mark for Review You create a Web application by using Microsoft ASP.NET 3.5. You create a base user control named AssignmentUserControl. Ten user controls derive from AssignmentUserControl. You add a PlaceHolder control named _placeHolder to a page. You create the following method to load one of the 10 user controls into _placeHolder: private void DisplayAssignmentUserControl(string userControlPath) { } The path of the user control to load is passed as a parameter to the method. You need to write code to load the user control. Your solution must support new AssignmentUserControl-derived user controls without the need to re- implement the method. Which code segment should you use?
  32. 32. AssignmentUserControl control = new AssignmentUserControl(); LoadControl(userControlPath); _placeHolder.Controls.Add(control); AssignmentUserControl control = new AssignmentUserControl(); control.ID = userControlPath; _placeHolder.Controls.Add(control); Control control _placeHolder.FindControl(userControlPath); _placeHolder.Controls.Add(control); Control control = LoadControl(userControlPath); _placeHolder.Controls.Add(control);Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-009 Jump to Question IDQuestion 13 Explanation:You should call the LoadControl method of the Page class to load the user control, andthen call the Add method of the _placeHolder instances Controls collection. TheLoadControl method loads a user control from a file and returns a Control instance thatrepresents the loaded user control. The Add method of the _placeHolder instancesControls collection adds the user control to the _placeHolder instance.You should not create an instance of AssignmentUserControl and add it to the_placeHolder instances Controls collection. To load a user control, you must call theLoadControl method of the Page class and specify the path to the user control as aparameter.You should not call the FindControl method of the _placeHolder instance to load a usercontrol. The FindControl method returns instances of controls that are already added toa controls hierarchy.Objective:List allquestionsfor thisobjective</ Consuming and Creating ServerP< td>Controls
  33. 33. Sub-Objective:2.2 Load user controls dynamically.References: 1. How to: Create Instances of ASP.NET User Controls Programmatically Click here for further information MSDN, MicrosoftQuestion 14 / 75 Mark for Review You create a Web application by using Microsoft ASP.NET 3.5. The following markup exists on a page: <asp:ScriptManager ID="_scriptManager" runat="server"/> <asp:UpdatePanel ID="_updatePanel" runat="server"> <ContentTemplate> <asp:GridView ID="_gridView" runat="server"/> <asp:Button ID="_submitButton" runat="server" Text="Submit"/> <asp:Button ID="_refreshButton" runat="server" Text="Refresh"/> </ContentTemplate> </asp:UpdatePanel> You need to write code so that the _refreshButton control causes the entire page to be posted back. Which code segment should you use? protected void Page_Load(object sender, EventArgs e) { Page.RegisterRequiresRaiseEvent(_refreshButton); } protected void Page_Load(object sender, EventArgs e) { Page.RegisterRequiresPostBack(_refreshButton); } protected void Page_Load(object sender, EventArgs e) {
  34. 34. _scriptManager.RegisterPostBackControl(_refreshButton); } protected void Page_Load(object sender, EventArgs e) { _scriptManager.RegisterAsyncPostBackControl(_refreshButton); }Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-018 Jump to Question IDQuestion 14 Explanation:You should call the RegisterPostBackControl method of the ScriptManager class. Thismethod instructs a control to always cause a full post back instead of an asynchronouspost back. By default, controls that are children of an UpdatePanel control performasynchronous post backs if the ChildrenAsTriggers property of the UpdatePanel controlis set to true, which is the default value. To prevent a child control from performing anasynchronous post back, you must either set ChildrenAsTriggers to false or call theRegisterPostBackControl method for the child control.You should not call the RegisterAsynchronousPostBackControl method of theScriptManager class. This method instructs a control to always perform anasynchronous post back.You should not call the RegisterRequiresPostBack method of the Page class. Thismethod instructs the page processor to call methods of the IPostBackDataHandlerinterface implemented by a control when a page post back occurs. It does not matterwhether the post back is a full post back or an asynchronous post back.You should not call the RegisterRequiresRaiseEvent method of the Page class. Thismethod instructs the page processor to call the RaisePostBackEvent method of theIPostBackEventHandler interface implemented by a control when a page post backoccurs. It does not matter whether the post back is a full post back or an asynchronouspost back.
  35. 35. Objective:List allquestionsfor thisobjective</ Working with ASP.NET AJAX andP< td>Client-Side ScriptingSub-Objective:5.1 Implement Web Forms by using ASP.NET AJAX.References: 1. ScriptManager Enables AJAX In Your Web Apps Click here for further information MSDN, Microsoft 2. ScriptManager.RegisterPostBackControl Method Click here for further information MSDN, Microsoft 3. ScriptManager.RegisterAsyncPostBackControl Method Click here for further information MSDN, MicrosoftQuestion 15 / 75 Mark for Review You create a Web application by using Microsoft ASP.NET 3.5. A page in the application allows users to dynamically configure its layout. By clicking a Button control on the page, users can dynamically add user controls to the page. The following code exists for the page: public partial class PortalPage : System.Web.UI.Page
  36. 36. { private int _sectionCount = 0; protected void AddButton_Click(object sender, EventArgs e) { Control control = this.Load("Section.ascx"); Controls.Add(control); _sectionCount++; } } You need to ensure that the page retains the dynamically-added user controls as it undergoes post-back requests. Your solution must not allow a configuration change to override this functionality. Which code segments should you use? (Each correct answer presents part of the solution. Choose three.)protected override LoadViewState(object savedState){_sectionCount = (int)savedState;}protected override object SaveViewState(){ViewState["SectionCount"] = _sectionCount;}protected override void LoadControlState(object savedState){Pair pair = (Pair)savedState;base.LoadControlState(pair.First);_sectionCount = (int)pair.Second;for (int index = 0; index < _sectionCount; index++){Control control = this.LoadControl("Section.ascx");Controls.Add(control);}}protected override object SaveControlState(){Pair pair = new Pair();pair.First = base.SaveControlState();pair.Second = _sectionCount;return pair;}protected override void OnInit(EventArgs e){Page.RegisterRequiresControlState(this);base.OnInit(e);}
  37. 37. Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-003 Jump to Question IDQuestion 15 Explanation:You should use control state to persist the count of the dynamically-added usercontrols. A developer or administrator cannot disable control state for a page through aconfiguration change. You should override SaveControlState to save the current countof dynamically-added user controls. However, you must also save the default controlstate of the page. To do this, you should create a Pair instance, which simply allows youto group two objects together. You should then return the Pair instance from themethod. The instance that you return is passed to the LoadControlState method whenthe page loads. This allows you to determine the number of user controls that weredynamically added during the last page request and recreate those controls. To enablecontrol state, you must call the RegisterRequiresControlState method of the Page class.You should call this method from within the OnInit method of the Page class.You should not override LoadViewState and SaveViewState. These methods give yougreater control over what is stored and retrieved from view state. However, a developeror administrator can disable view state for the page after the application is deployedthrough a configuration change.Objective:List allquestionsfor thisobjective</ Programming Web ApplicationsP< td>Sub-Objective:7.5 Implement session state, view state, control state, cookies, cache, or applicationstate.References: 1. Control State vs. View State Example Click here for further information MSDN, Microsoft
  38. 38. 2. ASP.NET State Management Overview Click here for further information MSDN, Microsoft 3. Page.RequiresControlState Method Click here for further information MSDN, MicrosoftQuestion 16 / 75 Mark for Review You create a Web application by using Microsoft ASP.NET 3.5. You create a custom server control named Circle, which exists in the BcdTrain.WebControls namespace. The control contains a single read-write property named Radius of type Double. You implement the control as an Asynchronous JavaScript and XML (AJAX) extender control that allows the Radius property to be set in client script. You implement the following code in an associated JavaScript file (line numbers are included for reference only): 01 Type.registerNamespace("BcdTrain.WebControls"); 02 BcdTrain.WebControls.Circle = function(elem) 03 { 04 BcdTrain.WebControls.Circle.initializeBase(this, elem); 05 this._radius = 0; 06 } 07 BcdTrain.WebControls.Circle.prototype = 08 { 09 initialize : function() 10 { 11 BcdTrain.WebControls.callBaseMethod(this, initialize); 12 }, 13 dispose : function() 14 { 15 BcdTrain.WebControls.callBaseMethod(this, dispose); 16 }, 17 18 } 19 BcdTrain.WebControls.Circle.registerClass(BcdTrain.WebControls.Circle, Sys.UI.Control); You need to define the Radius property in the JavaScript file: Which code segment should you insert at line 17?
  39. 39. Radius : function() { return this._radius; } get_Radius : function() { return this._radius; }, set_Radius : function(value) { this._radius = value; } Radius : function() { return this._radius; }, Radius : function(value) { this._radius = value; } Radius : function(value) { this._radius = value; }Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-067 Jump to Question IDQuestion 16 Explanation:You should use the following code segment:get_Radius : function(){return this._radius;},set_Radius : function(value){this._radius = value;}This code defines two functions named get_Radius and set_Radius. Because JavaScriptdoes not support the concept of properties, you must implement the Radius property as
  40. 40. two distinct functions with different names. The get_Radius function returns the valueof the Radius property. The set_Radius function sets the value of the Radius property.You should not use the following code segment:Radius : function(){return this._radius;},Radius : function(value){this._radius = value;}This code defines two functions with the same name. Because JavaScript does notsupport the concept of properties, you must implement the Radius property as twodistinct functions with different names.You should not use the following code segment:Radius : function(){return this._radius;}This code defines a single function that returns the value of the Radius property.However, you should also define a function that sets the value of the Radius property.You should not use the following code segment:Radius : function(value){this._radius = value;}This code defines a single function that sets the value of the Radius property. However,you should also define a function that returns the value of the Radius property.
  41. 41. Objective:List allquestionsfor thisobjective</ Working with ASP.NET AJAX andP< td>Client-Side ScriptingSub-Objective:5.2 Interact with the ASP.NET AJAX client-side library.References: 1. Adding ASP.NET AJAX Client Capabilities to a Web Server Control Click here for further information MSDN, Microsoft 2. ScriptManager Enables AJAX In Your Web Apps Click here for further information MSDN, Microsoft 3. An Introduction to JavaScript Object Notation (JSON) in JavaScript and .NET Click here for further information MSDN, Microsoft 4. Creating Custom Client Script by Using the Microsoft AJAX Library Click here for further information MSDN, MicrosoftQuestion 17 / 75 Mark for Review
  42. 42. You create a Web application by using Microsoft ASP.NET 3.5. You need to build the application and deploy it to a remote server. You use virtual private networking (VPN) to connect to the remote servers network. You are granted access to the folder where you need to deploy the application. Front Page Server Extensions are not installed on the remote server. You need to use Microsoft Visual Studio 2008 to deploy the application. Your solution must prevent access to source code files used by the application. What should you do? Use the Copy Web Site tool and choose the File System option. Use the Publish Web Site tool and choose the Remote Site option. Use the Publish Web Site tool and choose the File System option. Use the Copy Web Site tool and choose the Remote Site option.Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-056 Jump to Question IDQuestion 17 Explanation:You should use the Publish Web Site tool and choose the File System option. This allowsyou to compile and deploy the application to a local directory, network drive, or fileshare.You should not use the Publish Web Site tool and choose the Remote Site option. Thisoption requires that the server have Front Page Server Extensions installed.You should not choose the Copy Web Site tool. This tool copies project files, whichincludes source code, to a target location.Objective:List allquestionsfor thisobjective</ Configuring and Deploying WebP< td>
  43. 43. ApplicationsSub-Objective:1.5 Publish Web applications.References: 1. Walkthrough: Publishing a Web Site Click here for further information MSDN, Microsoft 2. Publish Web Site Dialog Box Click here for further information MSDN, Microsoft 3. How to: Publish Web Sites (Visual Studio) Click here for further information MSDN, MicrosoftQuestion 18 / 75 Mark for Review You create a Web site by using Microsoft ASP.NET 3.5. The following code exists in the App_Code folder: namespace BcdTrain.Providers { public class SessionSiteMapProvider : SiteMapProvider { // Members omitted for brevity } } You need to modify the Web.config file to ensure that SiteMapDataSource controls use the SessionSiteMapProvider class by default. Which configuration should you use?
  44. 44. <siteMap defaultProvider="BcdTrain.Providers.SessionSiteMapProvider"> </siteMap> <siteMap defaultProvider="SessionSiteMapProvider"> <providers> <add name="BcdTrain.Providers.SessionSiteMapProvider" type="SiteMapProvider" </providers> </siteMap> <siteMap defaultProvider="BcdTrain.Providers.SessionSiteMapProvider, App_Code"> </siteMap> <siteMap defaultProvider="SessionSiteMapProvider"> <providers> <add name="SessionSiteMapProvider" type="BcdTrain.Providers.SessionSiteMapProvider, App_Code" </providers> </siteMap>Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-034 Jump to Question IDQuestion 18 Explanation:You should use the following configuration:<siteMap defaultProvider="SessionSiteMapProvider"><providers><addname="SessionSiteMapProvider"type="BcdTrain.Providers.SessionSiteMapProvider, App_Code"</providers></siteMap>This configuration adds a site map provider named SessionSiteMapProvider that mapsto the SessionSiteMapProvider class in the BcdTrain.Providers namespace. The nameattribute specifies a user-friendly name of the provider. The type attribute specifies thefully-qualified type name of the provider in the form [Namespace].[Class], [Assembly].App_Code indicates that the assembly is one that is generated for code in theApp_Code folder. This configuration also sets the defaultProvider attribute to
  45. 45. SessionSiteMapProvider, which is the name of the provider that is added.SiteMapDataSource controls that do not specify a value for the SiteMapProviderproperty will automatically use the default provider.You should not use the following configuration:<siteMap defaultProvider="SessionSiteMapProvider"><providers><addname="BcdTrain.Providers.SessionSiteMapProvider"type="SiteMapProvider"</providers></siteMap>The defaultProvider attribute must match the name of a defined site map provider. Also,the type attribute must specify the fully-qualified type name of a site map provider.You should not use the following configuration:<siteMap defaultProvider="BcdTrain.Providers.SessionSiteMapProvider"></siteMap>The defaultProvider attribute must match the name of a defined site map provider. Inthis configuration, no additional site map providers are defined.You should not use the following configuration:<siteMap defaultProvider="BcdTrain.Providers.SessionSiteMapProvider, App_Code"></siteMap>The defaultProvider attribute must match the name of a defined site map provider. Inthis configuration, no additional site map providers are defined.Objective:List allquestionsfor thisobjective</ Configuring and Deploying WebP< td>Applications
  46. 46. Sub-Objective:1.1 Configure providers.References: 1. Implementing ASP.NET Site-Map Providers Click here for further information MSDN, Microsoft 2. How to: Configure Multiple Site Maps and Site-Map Providers Click here for further information MSDN, Microsoft 3. ASP.NET Site Maps Click here for further information MSDN, MicrosoftQuestion 19 / 75 Mark for Review You create a Web application by using Microsoft ASP.NET 3.5. The following code exists in the application: public class Account { public double Balance { get; set; } public void Deposit(double amount) { Balance += amount; } public void Withdraw(double amount) { System.Diagnostics.Trace.WriteLineIf(amount > Balance, "Potential Overdraft."); if (amount <= Balance) { Balance -= amount; }
  47. 47. } } This code writes a trace message if there is potential for an overdraft. You need to configure the Web.config file to write the trace message to the trace viewer tool (Trace.axd). Which configurations should you use? (Each correct answer presents part of the solution. Choose two.) <trace enabled="true"/> <system.diagnostics> <trace> <listeners> <add name="WebPageTraceListener" type="System.Web.WebPageTraceListener, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> </listeners> </trace> </system.diagnostics> <trace enabled="false" writeToDiagnosticsTrace="true"/> <trace enabled="false" writeToDiagnosticsTrace="true" pageOutput="false"/> <system.diagnostics> <switches> <add name="PageOutput" value="Trace.axd"/> </switches> </system.diagnostics>Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-040 Jump to Question IDQuestion 19 Explanation:You should use the following configuration:<system.diagnostics><trace><listeners><add name="WebPageTraceListener"
  48. 48. type="System.Web.WebPageTraceListener,System.Web,Version=2.0.3600.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a"/></listeners></trace></system.diagnostics>This adds a new trace listener to the Listeners collection of theSystem.Diagnostics.Trace class. The WebPageTraceListener class is implemented towrite diagnostic trace messages to the ASP.NET tracing subsystem. Whenever you writea trace message by using the System.Diagnostics.Trace class, that message is alsowritten to the ASP.NET tracing subsystem. You can view messages written to theASP.NET tracing subsystem by accessing Trace.axd in the current Web application.You should also use the following configuration:<trace enabled="true"/>This configuration enables ASP.NET tracing. If you do not enable ASP.NET tracing,nothing will be written to the ASP.NET tracing subsystem. Note that you must add thisconfiguration in the <system.web> section.You should not use the following configuration:<trace enabled="false" writeToDiagnosticsTrace="true"/>This configuration disables ASP.NET tracing. The writeToDiagnosticsTrace attributespecifies whether ASP.NET trace messages should be written to listeners defined fordiagnostic tracing. However, in this scenario, you need to write diagnostic tracemessages to the ASP.NET tracing subsystem.You should not use the following configuration:<trace enabled="false" writeToDiagnosticsTrace="true" pageOutput="false"/>This configuration disables ASP.NET tracing. The writeToDiagnosticsTrace attributespecifies whether ASP.NET trace messages should be written to listeners defined fordiagnostic tracing. However, in this scenario, you need to write diagnostic tracemessages to the ASP.NET tracing subsystem. The pageOutput attribute specifieswhether ASP.NET trace messages can be viewed by requesting pages in addition toTrace.axd.
  49. 49. You should not use the following configuration:<system.diagnostics><switches><add name="PageOutput" value="Trace.axd"/></switches></system.diagnostics>This configuration defines a trace switch named PageOutput that is set to the valueTrace.axd. Trace switches allow you to write conditional diagnostic trace messages in anapplication based on the value of the switch.Objective:List allquestionsfor thisobjective</ Troubleshooting and DebuggingP< td>Web ApplicationsSub-Objective:4.4 Implement tracing of a Web application.References: 1. Walkthrough: Integrating ASP.NET Tracing with System.Diagnostics Tracing Click here for further information MSDN, Microsoft 2. How to: View ASP.NET Trace Information with the Trace Viewer Click here for further information MSDN, Microsoft 3. How to: Enable Tracing for an ASP.NET Application Click here for further information MSDN, Microsoft 4. ASP.NET Tracing Overview
  50. 50. Click here for further information MSDN, MicrosoftQuestion 20 / 75 Mark for Review You create a Web application by using Microsoft ASP.NET 3.5. A page contains a DropDownList control named _cultureList. This control displays a list of languages to which the user interface can be localized. The page uses localized resources in the App_LocalResources folder. You need to write code to localize the page based on the selected language. Your solution must retain the localized version of the page across post-back requests. Which code segment should you use? protected override void OnInit(EventArgs e) { string culture = _cultureInfo.SelectedValue; Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture); } protected override void OnPreRender(EventArgs e) { string culture = _cultureInfo.SelectedValue; Thread.CurrentThread.CurrentCulture = new CultureInfo(culture); } protected override void OnPreInit(EventArgs e) { string culture = _cultureInfo.SelectedValue; Thread.CurrentThread.CurrentCulture = new CultureInfo(culture); } protected override void InitializeCulture() { string culture = Request.Form["_cultureList"]; if (culture != null) { Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture); } }
  51. 51. Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-005 Jump to Question IDQuestion 20 Explanation:You should override the InitializeCulture method and set the CurrentUICulture propertyof the current Thread instance. The CurrentUICulture property represents the userinterface culture. It specifies the culture that is used to read localized resources. ADropDownList control saves its selected value in an HTML form field. Because of this,you can easily determine the current culture by accessing the value of this field. Thisallows you to reset the CurrentUICulture property to the current culture across post-back requests.You should not set the CurrentUICulture property in the OnInit method. This willprevent the current culture from being retained across post-back requests.You should not set the CurrentCulture property. The CurrentCulture property allows youto specify a culture that is used to display and format numbers, currencies, dates andtimes. It does not specify the culture that is used to read localized resources.Objective:List allquestionsfor thisobjective</ Programming Web ApplicationsP< td>Sub-Objective:7.3 Implement globalization and accessibility.References: 1. How to: Set the Culture and UI Culture for ASP.NET Web Page Globalization Click here for further information MSDN, Microsoft
  52. 52. Question 21 / 75 Mark for Review You create a Web application by using Microsoft ASP.NET 3.5. Your application must load employee data from an XML file into a DataSet instance. The XML file contains an inline schema. You need to call a method of the DataSet class to load the data. What should you do? Call the ReadXml method with the ReadSchema XML read mode. Call the ReadXml method with the InferTypedSchema XML read mode. Call the ReadXmlSchema method. Call the ReadXml method with the InferSchema XML read mode.Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-062 Jump to Question IDQuestion 21 Explanation:You should call the ReadXml method with the ReadSchema XML read mode. Thismethod reads data and loads schema information from an inline schema.You should not call the ReadXml method with the InferSchema XML read mode. Thismethod loads data and infers the schema from the data. It does not read an inlineschema.You should not call the ReadXml method with the InferTypedSchema XML read mode.This method loads data and infers a strongly-typed schema from the data. It does notread an inline schema.
  53. 53. You should not call the ReadXmlSchema method. This method reads schemainformation from a schema file or stream. In this scenario, the XML file contains boththe schema and the data.Objective:List allquestionsfor thisobjective</ Working with Data and ServicesP< td>Sub-Objective:3.2 Manipulate data by using DataSet and DataReader objects.References: 1. Loading a DataSet from XML Click here for further information MSDN, Microsoft 2. XmlReadMode Enumeration Click here for further information MSDN, Microsoft 3. DataSet.ReadXml Method (Stream, XmlReadMode) Click here for further information MSDN, Microsoft
  54. 54. Question 22 / 75 Mark for Review You create a Web application by using Microsoft ASP.NET 3.5. You are dynamically loading a user control into a container on a page. You need to load the control during the correct page event so that the control participates in post back data processing and validation. What should you do? Handle the PreRender event and load the user control. Handle the Init event and load the user control. Handle the Load event and load the user control. Handle the SaveStateComplete event and load the user control.Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-041 Jump to Question IDQuestion 22 Explanation:You should handle the Init event and load the user control. This event is raised after acontrol is initialized. For a dynamically added user control to participate in post backdata processing and validation, you must load the control during the Init event.You should not handle the Load event and load the user control. This event is raisedafter the Init event, indicating that a control is loaded. For a dynamically added usercontrol to participate in post back data processing and validation, you must load thecontrol during the Init event.You should not handle the PreRender event and load the user control. This event israised just before the control is rendered. For a dynamically added user control to
  55. 55. participate in post back data processing and validation, you must load the controlduring the Init event.You should not handle the SaveStateComplete event and load the user control. Thisevent is raised after the PreRender event and after the controls view state and controlstate are saved. For a dynamically added user control to participate in post back dataprocessing and validation, you must load the control during the Init event.Objective:List allquestionsfor thisobjective</ Consuming and Creating ServerP< td>ControlsSub-Objective:2.2 Load user controls dynamically.References: 1. TemplateControl.LoadControl Method (String) Click here for further information MSDN, Microsoft 2. An Extensive Examination of User Controls Click here for further information MSDN, MicrosoftQuestion 23 / 75 Mark for Review
  56. 56. You create a Web application by using Microsoft ASP.NET 3.5. You write the following code to create a template control: [ParseChildren(true)] public class EmployeeViewer : Control, INamingContainer { public Employee Employee {get; set; } [TemplateContainer(typeof(EmployeeTemplateContainer))] public ITemplate EmployeeTemplate {get; set; } protected override void CreateChildControls() { } } public class EmployeeTemplateContainer : Control, INamingContainer { public Employee Employee {get; set; } } You need to implement the CreateChildControls method of the EmployeeViewer class so that content specified in the EmployeeTemplate property is rendered by the EmployeeViewer control. Which code segment should you use?if (this.EmployeeTemplate == null){this.Controls.Clear();EmployeeTemplateContainer container = new EmployeeTemplateContainer(){Employee = this.Employee;};this.Controls.Add(container);}if (this.EmployeeTemplate == null){this.Controls.Clear();EmployeeTemplateContainer container = new EmployeeTemplateContainer(){Employee = this.Employee;};this.EmployeeTemplate.InstantiateIn(container);this.Controls.Add(container);}if (this.EmployeeTemplate != null){this.Controls.Clear();EmployeeTemplateContainer container = new EmployeeTemplateContainer(){Employee = this.Employee;};this.Controls.Add(container);
  57. 57. } if (this.EmployeeTemplate != null) { this.Controls.Clear(); EmployeeTemplateContainer container = new EmployeeTemplateContainer() { Employee = this.Employee; }; this.EmployeeTemplate.InstantiateIn(container); this.Controls.Add(container); }Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-010 Jump to Question IDQuestion 23 Explanation:You should first determine whether the EmployeeTemplate property of theEmployeeViewer class returns a null reference. If it does not, this means that youshould render its contents. To do this, you must first create an instance of thetemplates container, which is EmployeeTemplateContainer. A template container allowsyou to store all of the templates content into a single container control. This allows youto render the content by simply adding the container to the templated controlshierarchy. To place the template into the container, you should call the InstantiateInmethod of EmployeeTemplate, passing to the method an instance of the container intowhich the template will be placed. This causes all markup between the<EmployeeTemplate> and </EmployeeTemplate> tags to be placed into theEmployeeTemplateContainer instance. You should then add theEmployeeTemplateContainer instance to the EmployeeViewer controls hierarchy.You should not instantiate the template into its container if the EmployeeTemplateproperty returns a null reference. A null reference indicates that there is no templatecontent to place in the container.You should not add the template container to the EmployeeViewer controls hierarchywithout first instantiating the template into its container. Otherwise, the markupspecified between the <EmployeeTemplate> and <EmployeeTemplate> tags will not getrendered.
  58. 58. Objective:List allquestionsfor thisobjective</ Consuming and Creating ServerP< td>ControlsSub-Objective:2.3 Create and consume custom controls.References: 1. Developing a Templated Control Click here for further information MSDN, Microsoft 2. Building Templated Custom ASP.NET Server Controls Click here for further information MSDN, MicrosoftQuestion 24 / 75 Mark for Review You create a Web application by using Microsoft ASP.NET 3.5. Your application displays order information from an XML file that does not contain an inline schema. A DataSet-compatible schema is stored in an XSD file. The schema defines a subset of the nodes that exist in the XML file. This schema should not be modified. You need to load the XML data so that it can be navigated relationally and with the XML Document Object Model (DOM). What should you do?
  59. 59. Load the XML file into a DataSet instance. Create an XmlDataDocument instance from the DataSet instance. Load the XSD file into a DataSet instance. Load the XML file into the DataSet instance by using the InferSchema read mode. Create an XmlDataDocument instance from the DataSet instance. Load the XSD file into a DataSet instance. Create an XmlDataDocument instance from the DataSet instance. Load the XML file into the XmlDataDocument instance. Load the XSD file and XML file into a DataSet instance. Create an XmlDataDocument instance from the DataSet instance. Load the XML file into the XmlDataDocument instance.Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-061 Jump to Question IDQuestion 24 Explanation:You should synchronize a DataSet instance with an XmlDataDocument instance. TheDataSet class allows you to expose XML data relationally. The XmlDataDocument classallows you to navigate data relationally and with the XML DOM. You should first load theXSD file into a DataSet instance. This defines the schema for the DataSet instance. Youshould then call the XmlDataDocument constructor, passing to it the DataSet instancethat should be synchronized. Finally, you should load the XML data into theXmlDataDocument instance. This allows the entire XML data to be navigated, whileallowing only the nodes defined in the XSD schema to be navigated relationally in theDataSet instance.Although you should load the XSD file into the DataSet instance, you should not loadthe XML file into the DataSet instance by using the InferSchema read mode. Thiscauses additional schema definitions to be inferred from the XML data and added to theexisting schema.You should not load the XML file into an XmlDataDocument instance that issynchronized with a DataSet instance that already contains data. This would throw anexception.You should not load the XML file without first loading the XSD file into the DataSetinstance. This would cause the DataSet instance to infer the schema from the XML file.
  60. 60. Objective:List allquestionsfor thisobjective</ Working with Data and ServicesP< td>Sub-Objective:3.1 Read and write XML data.References: 1. Synchronizing a DataSet with an XmlDataDocument Click here for further information MSDN, Microsoft 2. Loading a DataSet from XML Click here for further information MSDN, Microsoft 3. DataSet and XmlDataDocument Synchronization (ADO.NET) Click here for further information MSDN, Microsoft 4. XML Integration with Relational Data and ADO.NET Click here for further information MSDN, MicrosoftQuestion 25 / 75 Mark for Review
  61. 61. You create a Web application by using Microsoft ASP.NET 3.5. The following code exists in the code-behind file for a page named Admin.aspx: [WebMethod] public static string GetSessionObject(string key) { return HttpContext.Current.Session[key] as string; } You need to call the GetSessionObject method from JavaScript, passing to it the value of a TextBox control named _sessionKey. You must display the return value in a browser alert window. You need to modify the page to accomplish your goal. What should you do? (Each correct answer presents part of the solution. Choose two.)Add the following script block to the page:<script language="javascript" type="text/javascript">function GetSessionObject(){var sessionKey = $get(_sessionKey).value;var result = Admin.GetSessionObject(sessionKey);window.alert(result);}</script>Add the following script block to the page:<script language="javascript" type="text/javascript">function GetSessionObject(){var sessionKey = $get(_sessionKey).value;PageMethods.GetSessionObject(sessionKey, OnSuccess);}function OnSuccess(result){window.alert(result);}</script>Declare a ScriptManager control on the page as follows:<ScriptManager ID="_scriptManager" runat="server"EnablePageMethods="true"/>Declare a ScriptManager control on the page as follows:<ScriptManager ID="_scriptManager" runat="server"><Services><asp:ServiceReference Path="Admin.aspx"/></Services></ScriptManager>Add the following script block to the page:<script language="javascript" type="text/javascript">function GetSessionObject(){var sessionKey = $get(_sessionKey).value;
  62. 62. var result = PageMethods.GetSessionObject(sessionKey); window.alert(result); } </script>Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-024 Jump to Question IDQuestion 25 Explanation:You should declare a ScriptManager control on the page as follows:<ScriptManager ID="_scriptManager" runat="server" EnablePageMethods="true"/>The EnablePageMethods property specifies whether page methods are enabled for thepage. Page methods are public static methods that have the WebMethod attributeapplied. These methods can be called from JavaScript through AJAX requests. Settingthe EnablePageMethods property to true allows page methods to be called as Webmethods from a script on that page as if they were part of a Web service, but you donot have to create a separate .asmx file.You should add the following script block to the page:<script language="javascript" type="text/javascript">function GetSessionObject(){var sessionKey = $get(_sessionKey).value;PageMethods.GetSessionObject(sessionKey, OnSuccess);}function OnSuccess(result){window.alert(result);}</script>This script calls the GetSessionObject function of the PageMethods AsynchronousJavaScript and XML (AJAX) object. This function internally makes an AJAX request tothe server to invoke the corresponding GetSessionObject methods. When theEnablePageMethods property of the ScriptManager class is set to true, ASP.NET AJAXautomatically generates functions that have the same names as the page methods
  63. 63. defined for the page. The first parameters to a function match the parameters to thecorresponding page method. In addition, the function defines another parameter thatspecifies a callback function to invoke when the AJAX request completes. The parameterto the callback function is the return value from the page method.You should not declare a ScriptManager control on the page as follows:<ScriptManager ID="_scriptManager" runat="server"><Services><asp:ServiceReference Path="Admin.aspx"/></Services></ScriptManager>This declaration attempts to reference a Web service that can be called by AJAXrequests. In this scenario, Admin.aspx does not implement a Web service.You should not add the following script block to the page:<script language="javascript" type="text/javascript">function GetSessionObject(){var sessionKey = $get(_sessionKey).value;var result = PageMethods.GetSessionObject(sessionKey);window.alert(result);}</script>This script does not specify the callback function in the call toPageMethods.GetSessionObject. The call will return immediately because it isasynchronous. You must specify the callback function to retrieve the return value fromthe page method.You should not add the following script block to the page:<script language="javascript" type="text/javascript">function GetSessionObject(){var sessionKey = $get(_sessionKey).value;var result = Admin.GetSessionObject(sessionKey);window.alert(result);}</script>
  64. 64. This script attempts to call the GetSessionObject function of an Admin object. However,to call page methods, you must call functions of the PageMethods object.Objective:List allquestionsfor thisobjective</ Working with ASP.NET AJAX andP< td>Client-Side ScriptingSub-Objective:5.1 Implement Web Forms by using ASP.NET AJAX.References: 1. Exposing Web Services to Client Script Click here for further information MSDN, Microsoft 2. Calling Web Services from Client Script Click here for further information MSDN, Microsoft 3. ScriptManager.EnablePageMethods Property Click here for further information MSDN, MicrosoftQuestion 26 / 75 Mark for Review
  65. 65. You create a Web site by using Microsoft ASP.NET 3.5. You define a custom configuration section in the Web.config file. You obtain the source file containing the implementation of the configuration section. You need to configure the application so that the configuration section is processed by ASP.NET. What should you do? Add a Reference directive to the Global.asax file and set the VirtualPath attribute to the location of the source file. Add the source file to the App_Code folder. Add a Register directive to the Global.asax file and set the Src attribute to the location of the source file. Add the source file to the project as an embedded resource.Microsoft (70-562) TS: Microsoft .NET Framework 3.5 - ASP.NET ApplicationDevelopment (C#) (Preview)Question ID: jehMS_70-562CS-073 Jump to Question IDQuestion 26 Explanation:You should add the file to the App_Code folder of the project. The App_Code folderallows you to store utility classes for use in a Web site project. Code placed in thisfolder is dynamically compiled into an assembly. This allows ASP.NET to process thecustom configuration section when it processes the Web.config file.You should not add the source file to the project as an embedded resource. Embeddedresources are not compiled. You must compile the source file so that ASP.NET canprocess the custom configuration section.You should not add a Reference directive to the Global.asax file. This directive instructsASP.NET to dynamically compile a referenced page or user control when the requestingpage is compiled. This allows you to programmatically interact with the referenced pageor user control from the file in which the directive exists. Reference directives are notsupported in the Global.asax file.You should not add a Register directive to the Global.asax file. This directive allows youto register server controls and user controls on a page. Register directives are notsupported in the Global.asax file.

×