Search

ASHX handler to speak

A Generic Web handler ( *.ashx , extension based processor) is the default HTTP handler for all Web handlers that do not have a UI and that include the @WebHandler directive. ASP.NET page handler ( *.aspx ) is the default HTTP handler for all ASP.NET pages. It speaks what ever is the passed through url query string [text]
//Speak Asp.net handler, Speak.ashx
<%@ WebHandler Language="C#" Class="Speak" %>
using System;
using System.Web;
public class Speak : IHttpHandler
{
public void ProcessRequest (HttpContext context)
{
System.Speech.Synthesis.SpeechSynthesizer ssy = new System.Speech.Synthesis.SpeechSynthesizer();
string message = context.Request.QueryString["text"];
ssy.Speak(message);
context.Response.ContentType = "text/plain";
context.Response.Write(message);
}
public bool IsReusable
{
get{return false;}
}
}