Similar to this - How to call HttpHandler from .cs file asp.net
You need to provide an absolute URI. Also note that the ReadToEnd()
call will do precisely that; subsequently calling ReadLine
will return an empty string.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost:11034/handlers/handler1.ashx");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (response)
{
StreamReader reader = new StreamReader(response.GetResponseStream());
Label1.Text = reader.ReadToEnd();
}