News:
<configuration>
<system.net>
<mailSettings>
<smtp configSource="smtp.config" allowOverride="true">
<network host="127.0.0.1" port="25"/>
</smtp>
</mailSettings>
</system.net>
</configuration>
<configuration>
<system.net>
<mailSettings>
<smtp configSource="smtp.config" />
</mailSettings>
</system.net>
</configuration>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML- Document-Transform">
<location path="smtp.config" xdt:Transform="Replace"
xdt:Locator="Match(path)">
<system.net />
</location>
</configuration>
<configuration>
<location path="smtp.config">
<system.net>
<mailSettings>
<smtp Devilery Method="Network" >
<Network Host = "127.0.0.1" Port="25"/>
</smtp>
</mailSettings>
</system.net>
</location>
</configuration>
Run the aspnet_regiis.exe command
Set the Treat warnings as errors option to All in the project properties and recompile.
Add the following rule to the <healthMonitoring/> section of the web.config file.
<rules>
<add name="Failures"
eventName="Failure Audits"
provider="EventLogProvider" />
</rules>
Add the following rule to the <healthMonitoring/> section of the web.config file.
<rules>
<add name="Errors"
eventName="All Errors"
provider="EventLogProvider" />
</rules>
dtlView.DataSource = GetCustomerOrderDataSet(); dtlView.DataMember = "OrderDetailsTable"; dtlView.DataBind();
dtlView.DataSource = GetCustomerOrderDataSet(); dtlView.DataSourceID = "OrderDetailsTable"; dtlView.DataBind();
dtlView.DataSource = GetCustomerOrderDataSet(); dtlView.DataKeyNames = new string [] { "OrderDetailsTable"}; dtlView.DataBind();
DataSet dataSet = GetCustomerOrderDataSet(); dtlView.DataSource = new DataTable("dataSet", "OrderDetailsTable"); dtlView.DataBind();
<asp:ObjectDataSource SelectMethod="GetProductByProductId" ID="odc" runat="server" TypeName="ProductDAL">
<SelectParameters>
<asp:Parameter Name="productId" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
The page will be called with a query string field named pid. You need to configure the ObjectDataSource control to pass the value of the pid field to GetProductsByProductId method. What should you do?
Replace the asp:QueryStringParameter with the following declaration.
<asp:QueryStringParameter DefaultValue="pid" Name="productId" Type="Int32" />
Replace the asp:QueryStringParameter with the following declaration.
<asp:QueryStringParameter QueryStringField="pid" Name="productId" Type="Int32" />
Add the following event handler to the Selecting event of the ObjectDataSource control.
protected void odc_Selecting(object sender,ObjectDataSourceSelectingEventArgs e)
{
}
InputParameters["pid"] = Request.QueryString["productId"]; }
Add the following code segment to the page's code-behind.
protected void Page_Load(object sender, EventArgs e) { odc.SelectParameters.Add("productId", Request.QueryString["pid"]); }
<asp:SqlDataSource id="sqlds" runat="server" ConnectionString="<%$ ConnectionStrings:MyDB %>" SelectCommand="SELECT * FROM Companies" />
The page is accessed frequently, but the data in the database rarely changes. You need to cache the retrieved data so that the database is not queried each time the Web page is accessed. What should you do?
Add the following attributes to the SqlDataSource control.
DataSourceMode="DataSet" EnableCaching="True" CacheDuration="120"
Add the following attributes to the SqlDataSource control.
DataSourceMode="DataReader" EnableCaching="True" CacheDuration="120"
Add the following configuration to the <system.web/> section of the web.config file.
<caching>
<sqlCacheDependency enabled="true">
<databases>
<add name="MyDBCache"
connectionStringName="MyDB"
pollTime="120" />
</databases>
</sqlCacheDependency>
</caching>
Add the following configuration to the <system.web/> section of the web.config file.
<caching>
<sqlCacheDependency enabled="true" pollTime="120">
<databases>
<add name="MyDBCache"
connectionStringName="MyDB" />
</databases>
</sqlCacheDependency>
</caching>
public string JsonValue; List people = GetPeopleList(); JavaScriptSerializer json = new JavaScriptSerializer();
You need to use the JavaScriptSerializer class to serialize only the Name property of each item in the people list. Which code segment should you use?
JsonValue = json.Serialize(people.Select(p => p.Name));
var names = from person in people select person; JsonValue = "{" + json.Serialize(names) + "}";
JsonValue = json.Serialize(people.SelectMany( p =>p.Name.AsEnumerable()));
var names = from person in people select person; JsonValue = json.Serialize(names);
private NorthwindContext _entities; public void UpdatePerson(Person personToEdit) { }
You need to implement the UpdatePerson method to update the database row that corresponds to the personToEdit object. Which code segment should you use?
_entities.People.Attach(personToEdit); _entities.ObjectStateManager.ChangeObjectState( personToEdit, EntityState.Modified); _entities.SaveChanges();
_entities.ObjectStateManager.ChangeObjectState( personToEdit, EntityState.Added); _entities.SaveChanges();
_entities.People.ApplyCurrentValues(personToEdit); _entities.SaveChanges();
_entities.People.Attach(new Person() { Id = personToEdit.Id }); _entities.ObjectStateManager. ChangeObjectState( personToEdit, EntityState.Modified); _entities.SaveChanges();
public List GetNonSecretUsers() { string[] secretUsers = {"@secretUser", "@admin", "@root"}; List allpeople = GetAllPeople(); ... }
You need to add code to return a list of all Person objects except those with a UserId that is contained in the secretUsers list. The resulting list must not contain duplicates. Which code segment should you use?
var secretPeople = (from p in allPeople from u in secretUsers where p.UserId == u select p).Distinct(); return allPeople.Except(secretPeople);
return from p in allPeople from u in secretUsers where p.UserId != u select p;
return (from p in allPeople from u in secretUsers where p.UserId != u select p).Distinct();
List people = new List( from p in allPeople from u in secretUsers where p.UserId != u select p); return people.Distinct();
public class ProductService : System.Web.Services.WebService { public List GetProducts(int categoryID) { return GetProductsFromDatabase(categoryID); } }
You need to ensure that the GetProducts method can be called by using AJAX. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.)
Apply the WebService attribute to the ProductService class.
Apply the ScriptService attribute to the ProductService class.
Apply the WebMethod attribute to the GetProducts method.
Apply the ScriptMethod attribute to the GetProducts method.
namespace ContosoWCF { [ServiceContract] public interface IRateService { [OperationContract] decimal GetCurrentRate(); } public partial class RateService : IRateService { public decimal GetCurrentRate() { decimal currentRate = GetRateFromDatabase(); return currentRate; } } }
You build the service library and deploy its assembly to an IIS application. You need to ensure that the GetCurrentRate method can be called from JavaScript. What should you do?
Add a file named Service.svc to the IIS application.
Add the following code segment to the file.
<%@ ServiceHost Service="ContosoWCF.IRateService" Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory" %>
Add a file named Service.svc to the IIS application.
Add the following code segment to the file.
<%@ ServiceHost Service="ContosoWCF.RateService" Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory" %>
Apply the script service attribute to rate serice class Rebulid the WCF servicelibrary, and redploy the assembly to the IIS application.
Apply the Web get attibute to the Get Currant rate interface Method.Rebuild the WCF servicelibrary, and redploy the assembly to the IIS application.