.net 环境下创建WebService 学习笔记一

调用本地解决方案中的WebService

添加新项->Web服务(WebService.asmx)

在WebService.cs中添加方法(简单加法)Add(int a,int b)

代码:

[WebMethod]
 public int Add(int a,int b) {
        return a+b;
 }

保存

在WebPage(Default.aspx)中调用

先添加web引用->此解决方案中的Web服务->添加WebService.asmx引用(引用名;testWebService)

在Default.aspx中的添加TextBox1,TextBox2,label1,button1

在button1的触发事件中添加调用代码:

testWebService.WebService test=new testWebService();

int a=Convert.ToInt32(TextBox1.text);

int b=Convert.ToInt32(TextBox2.text);

int c;

c=test.Add(a,b);

label1.text=c.toString();

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值