私はこのコードを持っており、正常に動作しますが、ユーザーがダウンロードして聞くのではなく、ページに埋め込むことができる wav ファイルを出力する方法に苦労しています。どんな助けでも大歓迎です。キャプチャ テキストと一致するように、クエリ文字列を使用してファイルを直接呼び出すことができるようにしたいと考えています。Model.InstanceData["Code"] はテキスト文字列のキャプチャです。私はそれについて頭を包むことができないようです。ありがとう!
private void _playBtn_Click(object sender, ImageClickEventArgs e)
{
HttpContext context = HttpContext.Current;
if (context == null || context.Response == null)
{
return;
}
context.Response.Clear();
context.Response.AddHeader("content-disposition", "attachment; filename=" + "captcha.wav");
context.Response.AddHeader("content-transfer-encoding", "binary");
context.Response.ContentType = "audio/wav";
SoundGenerator soundGenerator = new SoundGenerator(Model.InstanceData["Code"]);
MemoryStream sound = new MemoryStream();
// Write the sound to the response stream
soundGenerator.Sound.Save(sound, SoundFormatEnum.Wav);
sound.WriteTo(context.Response.OutputStream);
}