Silverlight调用一般性处理程序模拟Silverlight调用WCF效果

Silverlight调用一般性处理程序模拟Silverlight调用WCF效果,第1张

概述               分类: 技术 2012-03-31 12:51 642人阅读 评论(0) 收藏 举报 silverlight wcf object string 服务器 class 代码下载 移动终端如果不想使用WCF,也可以调用一般性处理程序模拟对服务器数据调用。 Silverlight调用一般性处理程序模拟Silverlight调用WCF效果避免跨域访问问题 实现关键技术代码                分类: 技术 2012-03-31 12:51 642人阅读 评论(0) 收藏 举报 silverlight wcf object string 服务器 class

代码下载

移动终端如果不想使用WCF,也可以调用一般性处理程序模拟对服务器数据调用。

Silverlight调用一般性处理程序模拟Silverlight调用WCF效果避免跨域访问问题

实现关键技术代码如下:

1.Web建立一般性处理程序
   public class Handler1 : IhttpHandler
    {
        public voID ProcessRequest(httpContext context)
        {
            context.Response.ContentType = "text/plain";
          
            string username = context.Request["Username"];
            string psw = context.Request["Psw"];
            if (username == "admin" && psw == "123")
            {
                context.Response.Write("登陆成功");
            }
            else
            {
                context.Response.Write("登陆失败");
            }
        }
   
    }
2.Silverlight客户端异步调用
 private voID btnLogin_Click(object sender,RoutedEventArgs e)
        {
            WebClIEnt wb = new WebClIEnt();
            wb.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wb_DownloadStringCompleted);
            wb.DownloadStringAsync(new Uri("
http://localhost:8888/Handler1.ashx?UserName=" + this.txtUsername.Text + "&Psw=" + this.txtPsw.Password));

        }

        voID wb_DownloadStringCompleted(object sender,DownloadStringCompletedEventArgs e)         {             MessageBox.Show(e.Result.ToString());         }

总结

以上是内存溢出为你收集整理的Silverlight调用一般性处理程序模拟Silverlight调用WCF效果全部内容,希望文章能够帮你解决Silverlight调用一般性处理程序模拟Silverlight调用WCF效果所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1016265.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存