Silverlight 调用 aspx 相关文件

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            WebClient wb = new WebClient();
            wb.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wb_DownloadStringCompleted);
            wb.DownloadStringAsync(new Uri("http://localhost:49380/Extension/Handler1.ashx?UserName=" + this.txtUserName.Text + "&Psw=" + this.txtPsw.Text));
        }

        void wb_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            MessageBox.Show(e.Result.ToString());
        }
 public class Handler1 : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
           // context.Response.Write("Hello World");

            string userName = context.Request["UserName"];
            string psw = context.Request["Psw"];
            if (userName == "Admin" && psw == "123")
            {
                context.Response.Write("登陆成功");
            }
            else
            {
                context.Response.Write("登陆失败");
            }


        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

 

posted @ 2013-07-25 11:58  Space Tian  阅读(282)  评论(0编辑  收藏  举报