how to call ASHX handler and getting the result back

微笑、不失礼 提交于 2019-12-03 14:19:38

Use WebClient.DownloadString

WebClient client = new WebClient ();
Label1.Text = client.DownloadString ("http://somesite.com/Stores/GetOrderCount.ashx?sCode=VIC");

You could also directly call your handler using ajax and update the label.

Here is a jQuery example:

$.get('Stores/GetOrderCount.ashx?sCode=VIC', function(data) {
  $('.result').html(data);
});

Try this

System.IO.Stream stream = response.GetResponseStream();
System.IO.StreamReader reader = new System.IO.StreamReader(stream);
string contents = reader.ReadToEnd();
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!