Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Building a Web Application to consume a WCF Service

Avatar of maaknplan
maaknplanFlag for South Africa asked on
WCF
2 Comments1 Solution596 ViewsLast Modified:
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.

 
<%@ 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>
<%@ 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>
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);
        }
ASKER CERTIFIED SOLUTION
Avatar of gyoreg
gyoregFlag of Hungary image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answers