一個簡單的WCF for WebForm步驟
1. create "WCF service Application" project
2. create "Web Form" project
3. run WCF project ,get/copy address of WCF service
4. add services reference to "Web Form" project
5. add test code
6. set both project as start project(in solution)
*.aspx
*.aspx.cs
protected void Button1_Click(object sender, EventArgs e)
{
ServiceReference1.Service1Client ser1 = new ServiceReference1.Service1Client();
int i;
bool b = int.TryParse(TextBox1.Text, out i);
Label1.Text = ser1.GetData(i).ToString();
}
*.svc.cs(service )
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}