Exam 70-562 : Microsoft .NET Framework 3.5, ASP.NET Application Development – 16

Question: You work as a Web Developer at Company.com. You are in the process of creating a Web application that uses Microsoft ASP.NET 3.5. This application will be part of a solution that contains a Windows Communication Foundation (WCF) service project. The Web application will be used to make calls to a service identified in the WCF service project. Management is planning to host the Web application on a separate server from the WCF service. They want the WCF service to perform remotely. You need to add a reference to the WCF service. What should you do?

  1. You should add an assembly reference to the project.
  2. You should add a project reference to the project.
  3. You should add a Web reference to the project.
  4. You should add a service reference to the project.

Correct Answer: 4


Question: You work as an application developer at Company.com. You are in the process of creating an ASP.NET application that uses Microsoft .NET Framework 3.5. This application will make use of the Microsoft Windows Communication Foundation (WCF) service that exposes the method below:

[WebInvoke]
string UpdateDetails(string detID); 

The Microsoft Windows Communication Foundation (WCF) service is hosted by an application that has the code below:

WebServiceHost wcf1 = new WebServiceHost(typeof(CService), new Uri("http://wcf/"));
ServiceEndpoint endpnt = wcf1.AddServiceEndpoint(typeof(ICService), new WebHttpBinding(), ""); 

You receive a request from management to invoke the UpdateDetails method. What should you do?

  1. You should consider using:
    ChannelFactory<ICService> cfact = new ChannelFactory<ICService>(new WebHttpBinding(), “http://wcf/UpdateDetails”)
    ICService chnl = cfact.CreateChannel();
    string str = chnl.UpdateDetails(“detID23”);
  2. You should consider using:
    ChannelFactory<ICService> cfact = new ChannelFactory<ICService>(new BasicHttpBinding(), “http://wcf “)
    cfact.Endpoint.Behaviors.Add(new WebHttpBehavior());
    ICService chnl = cfact.CreateChannel();
    string str = chnl.UpdateDetails(“detID23”);
  3. You should consider using:
    WebChannelFactory<ICService> wfact = new WebChannelFactory<ICService>(new Uri(“http://wcf/UpdateDetails”))
    ICService chnl = wfact.CreateChannel();
    string str = chnl.UpdateDetails(“detID23”);
  4. You should consider using:
    WebChannelFactory<ICService> wfact = new WebChannelFactory<ICService>(new Uri(“http://wcf”))
    ICService chnl = wfact.CreateChannel();
    string str = chnl.UpdateDetails(“detID23”);

Correct Answer: 4


Question: You work as a Web Developer at Company.com. You make use of Microsoft ASP.NET 3.5 to create a Web application. The following code exists in the application:

public class UserSession
{
private string _webServer;
public UserSession(string webServer)
{
_webServer = webServer;
}
public DataSet GetUsers()
{
// Omitted for brevity
}
}

You receive an instruction from the senior developer to bind the DataSet instance returned from the GetUsers method to a data bound control. The parameter to the UserSession constructor is indicated in a query string parameter named WebServer. You decide to configure the ObjectDataSource control in order to accomplish this goal. What should you do? (Choose all that apply)

  1. You should add the code:
    protected void OnSelect(object sender, ObjectDataSourceSelectingEventArgs e)
    {
    string webServer = Request.QueryString[“WebServer”];
    e.InputParameters[0] = new UserSession(webServer);
    }
  2. You should consider creating the ObjectDataSource control as follows:
    ObjectDataSource dataSource = new ObjectDataSource();
    dataSource.SelectMethod = “GetUsers”;
    dataSource.Selecting = new ObjectDataSourceSelectingEventHandler(OnSelect);
    Controls.Add(dataSource);
  3. You should consider creating the ObjectDataSource control as follows:
    ObjectDataSource dataSource = new ObjectDataSource();
    dataSource.Created = new ObjectDataSourceObjectEventHandler(OnCreate);
    dataSource.SelectMethod = “GetUsers”;
    QueryStringParameter parameter = new QueryStringParameter();
    parameter.Name = “webServer”;
    parameter.QueryStringField = “WebServer”;
    dataSource.SelectParameters.Add(parameter);
    Controls.Add(dataSource);
  4. You should consider declaring the ObjectDataSource control as follows:
    <asp:ObjectDataSource ID=”_objectDataSource” runat=”server”
    TypeName=”UserSession” SelectMethod=”GetUsers”
    OnObjectCreating=”OnCreate”/>
  5. You should add the code:
    protected void OnCreate(object sender, ObjectDataSourceEventArgs e)
    {
    UserSession userSession = new UserSession(Request.QueryString[“WebServer”]);
    e.ObjectInstance = userSession;
    }

Correct Answer: 4,5


Question: You work as a Web Developer at Company.com. You are in the process of creating a Web application. You decide to make use of Microsoft ASP.NET 3.5 in order to create the application. The following markup is present on the page:

<asp:TextBox ID="_statusTextBox" runat="server"/>
<asp:Button ID="_button" runat="server" Text="Filter"/>
<asp:SqlDataSource ID="_sqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:Company %>"
SelectCommand="GetUsers" SelectCommandType="StoredProcedure" FilterExpression="Active=1 AND Name LIKE '{0}%'">
<FilterParameters>
<asp:ControlParameter ControlID="_statusTextBox"/>
</FilterParameters>
</asp:SqlDataSource>
<asp:GridView ID="_ckGridView" runat="server" DataSourceID="_sqlDataSource"/> 

The page is used to retrieve the Users from a company database. However, only the active users are displayed. The TextBox control allows you to also filter users by status. You do not specify a status when you click the Filter button. You notice that the page does not filter by active users and shows all the users that are retrieved from the database. You need to make the necessary settings to ensure that only the active users are being displayed on the page when a status is not specified. What should you do?

  1. You should ensure that a default value for the Status property of the ControlParameter control is set.
  2. You should ensure that the PropertyName property of the ControlParameter control is set to Text.
  3. You should ensure that the ControlParameter control’s ConvertEmptyStringToNull property is set to false.
  4. You should ensure that the {0} placeholder in the FilterExpression property is replaced with the (?) symbol.

Correct Answer: 3


Question: You work as a Web Developer at Company.com. You are in the process of creating a Web site using Microsoft ASP.NET 3.5. There is a folder named App_Code on the Web site. 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"]; }
}
} 

In a Microsoft SQL Server 2008 database the following stored procedures is present:

CREATE PROCEDURE GetStoresByUser @UserID INT AS
SELECT StoreID, StoreName FROM Store where UserID=@UserID 

A connection string named DataSupply is stored in the connectionStrings section. You need to make use of a data source control in order to call the stored procedure. Thereafter the Security.UserID value should be passed to it as a parameter. You need to determine the declaration that will accomplish this?

  1. <SqlDataSource ID=”_dataSource” runat=”server” ConnectionString=”<%$ ConnectionStrings:DataSupply%SupplyChain%>” SelectCommand=”GetStoresByUser” SelectCommandType=”Text”>
    <SelectParameters>
    <cust:ObjectParameter Name=”Security.UserID”/>
    </SqlDataSource>
  2. <ObjectDataSource ID=”_dataSource” runat=”server” DataObjectTypeName=”<%$ ConnectionStrings: DataSupply%SupplyChain%>” TypeName=”StoredProcedure” SelectMethod=”GetStoresByUser”>
    <SelectParameters>
    <cust:ObjectParameter Name=”UserID” ObjectTypeName=”Security” PropertyName=”UserID”/>
    </SelectParameters>
    </ObjectDataSource>
  3. <SqlDataSource ID=”_dataSource” runat=”server” ConnectionString=”<%$ ConnectionStrings: DataSupply%SupplyChain%>” SelectCommand=”GetStoresByUser” SelectCommandType=”StoredProcedure”>
    <SelectParameters>
    <cust:ObjectParameter Name=”UserID” ObjectTypeName=”Security” PropertyName=”UserID”/>
    </SelectParameters>
    </SqlDataSource>
  4. <ObjectDataSource ID=”_dataSource” runat=”server” DataObjectTypeName=”StoredProcedure” TypeName=”ConnectionStrings. DataSupply”SupplyChain” SelectMethod=”GetStoresByUser”>
    <SelectParameters>
    <cust:ObjectParameter Name=”Security.UserID”/>
    </SelectParameters>
    </ObjectDataSource>

Correct Answer: 3

Tagged . Bookmark the permalink.

Leave a Reply