What should you do?
You are upgrading a standalone Windows Presentation Foundation (WPF) application and an XAML browser application (XBAP) to Microsoft .NET Framework 4. You plan to add .NET 4 types and members to both applications. Both applications consume a common utility assembly that modifies files on a local file system. The utility assembly requires full trust. You need to ensure that both applications can use the common utility assembly without any securityrelated exceptions. What should you do?
Which code segment should you insert at line 08?
You use Microsoft .NET Framework 4.0 to develop an application that connects to a Microsoft SQL Server 2008 database.
You add the following table to the database.
CREATE TABLE Orders(
ID numeric(18, 0) NOT NULL,
OrderName varchar(50) NULL,
OrderTime time(7) NULL,
OrderDate date NULL)
You write the following code to retrieve data from the OrderTime column. (Line numbers are included for reference only.)
01 SqlConnection conn = new SqlConnection(“”);
02 conn.Open();
03 SqlCommand cmd = new SqlCommand(“SELECT ID, OrderTime FROM Orders”, conn);
04 SqlDataReader rdr = cmd.ExecuteReader();
05 ….
06 while(rdr.Read())
07 {
08 ….
09 }
You need to retrieve the OrderTime data from the database. Which code segment should you insert at line 08?
Which control markup should you use?
You are implementing an ASP.NET page that includes a text box.
You need to validate values that are typed by users to ensure that only numeric values are submitted.
Which control markup should you use?
Which approach should you recommend?
You are designing a user input form that is part of an ASP.NET Web Forms application.
You need to ensure that users cannot attack the Web server by submitting invalid data.
Which approach should you recommend?
Which code fragment should you use?
Which code segment should you use?
You use Microsoft .NET Framework 4.0 to develop an application. You use the XmlReader class to load XML from a location that you do not control.
You need to ensure that loading the XML will not load external resources that are referenced in the XML.
Which code segment should you use?
What should you do?
You are developing a Web page.
The user types a credit card number into an input control named cc and clicks a button named submit.
The submit button sends the credit card number to the server.
A JavaScript library includes a CheckCreditCard function that returns a value of true if the credit card appears to be valid, based on its checksum.
You need to ensure that the form cannot be used to submit invalid credit card numbers to the server.
What should you do?
Which approach should you recommend?
You are designing an ASP.NET Web Forms application that uses a database containing user names and hashed passwords for authentication. The Web application includes a login form in which users type their user names and passwords.
You need to design a strategy to ensure that the users login credentials cannot be stolen through a man-in-the-middle attack.
Which approach should you recommend?
What should you do?
You are designing a Windows application by using Microsoft .NET Framework 4 and Microsoft Visual Studio 2010. The business logic layer of the application is implemented by using Windows Communication Foundation (WCF). You create a duplex bidirectional WCF service that contains a single operation. The service operation sends the result back to the client application by using a twoway callback operation. You plan to design a service interaction strategy. You need to ensure that deadlocks are prevented. What should you do?
Which line of code should you insert at line 21?
You use Microsoft .NET Framework 4.0 to develop an application that connects to two separate Microsoft SQL Server 2008 databases.
The Customers database stores all the customer information, and the Orders database stores all the order information.
The application includes the following code. (Line numbers are included for reference only.)
01 try
02 {
03 conn.Open();
04 tran = conn.BeginTransaction(“Order”);
05 SqlCommand cmd = new SqlCommand();
06 cmd.Connection = conn;
07 cmd.Transaction = tran;
08 tran.Save(“save1”);
09 cmd.CommandText = “INSERT INTO [Cust].dbo.Customer ” + “(Name, PhoneNumber) VALUES (‘Paul Jones’, ” + “‘404-555-1212’)”;
10 cmd.ExecuteNonQuery();
11 tran.Save(“save2”);
12 cmd.CommandText = “INSERT INTO [Orders].dbo.Order ” + “(CustomerID) VALUES (1234)”;
13 cmd.ExecuteNonQuery();
14 tran.Save(“save3”);
15 cmd.CommandText = “INSERT INTO [Orders].dbo.” + “OrderDetail (OrderlD, ProductNumber) VALUES” + “(5678, ‘DC-6721’)”;
16 cmd.ExecuteNonQuery();
17 tran.Commit();
18 }
19 catch (Exception ex)
20 {
21 …
22 }
You run the program, and a timeout expired error occurs at line 16. You need to ensure that the customer information is saved in the database.
If an error occurs while the order is being saved, you must roll back all of the order information and save the customer information.
Which line of code should you insert at line 21?