Question : Building a Web Application to consume a WCF Service

I am following a WCF tutorial at http://msdn.microsoft.com/en-us/library/ms734712.aspx. The tutorial itself is straight forward and I have had no issues.

However I am trying to extend the tutorial to a web application, the code for the default.aspx is attached below.

I created the generateProxy.cs and app.Config file as per the tutorial, however when I start the service and try to debug the website, I get the following error:

InvalidOperationException was unhandled by user code
Could not find default endpoint element that references contract 'ICalculator' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element

Is there something different I need to do for a web application as opposed to a console application?

Thanks for any help.

 
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WCFTest._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>calculator test</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="txtN1" Columns="4" runat="server"></asp:TextBox> + 
        <asp:TextBox ID="txtN2" Columns="4" runat="server"></asp:TextBox> = 
        <asp:TextBox ID="txtTotal" runat="server" Columns="8"></asp:TextBox>
        <br />
        <asp:Button ID="btnSubmit" runat="server" Text="Submit" 
            onclick="btnSubmit_Click" />
    </div> 
    </form>
</body>
</html>

 
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WCFTest._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>calculator test</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="txtN1" Columns="4" runat="server"></asp:TextBox> + 
        <asp:TextBox ID="txtN2" Columns="4" runat="server"></asp:TextBox> = 
        <asp:TextBox ID="txtTotal" runat="server" Columns="8"></asp:TextBox>
        <br />
        <asp:Button ID="btnSubmit" runat="server" Text="Submit" 
            onclick="btnSubmit_Click" />
    </div> 
    </form>
</body>
</html>
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
protected void btnSubmit_Click(object sender, EventArgs e)
        {
            CalculatorClient client = new CalculatorClient();

            double n1 = Convert.ToDouble(txtN1.Text);
            double n2 = Convert.ToDouble(txtN2.Text);

            double total = client.Add(n1, n2);
            txtTotal.Text = string.Format("{0}", total);
        }

Answer : Building a Web Application to consume a WCF Service

Most likely it shorted the power port that pulls power from the docking station or a thermal regulator on the motherboard.  If the laptop was powered on while still wet there is really nothing that can be done as the damage would have allready been done.  If the laptop is still damp I would let it dry THOROUGHLY and try again.A good way to dry the unit although it sounds silly is to put it in a pillow case or some kind of protection and cover it in dry rice.  The rice will wick the moisture out of the device.  Always amuses me when users spill something on their laptops and then get ticked at the equipment.  Good Luck
Random Solutions  
 
programming4us programming4us