how to call ASHX handler and getting the result back how to call ASHX handler and getting the result back asp.net asp.net

how to call ASHX handler and getting the result back


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();