私はweb.configのトレースpageoutput = "true"を有効にしました。私は、ページの一番下にすべてのものを見ることができる簡単な方法が好きです。httphandlerのcontext.responseにトレース出力を追加する方法は?
私はhttphandlerの出力の下にあるトレースから同じ出力を得たいと思っています。
public class UploadHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
}
public bool IsReusable
{
get
{
return false;
}
}
}
私は特にフォームとのQueryStringコレクションを見てみたいが、このすべてが与えるが、「Hello World」のである。このコードをたどるコードを経由して同じトレース情報をダンプする方法はあります。
- 編集更新2009年7月25日:
public class UploadHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
object htw = new System.Web.UI.Html32TextWriter(context.Response.Output);
{
typeof(TraceContext)
.GetMethod("Render", System.Reflection.BindingFlags.NonPublic)
.Invoke(HttpContext.Current.Trace, new object[] { htw });
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
私はまたpageOutputトレースがないように、最も簡単な形態とクエリ文字列コレクションのフォーマットされたダンプを取得する方法についての他のアイデアを開いています。
は、あなたの使用してブロックを試してみましたが、彼はIDisposableインターを実装する必要が不満ので、私が試した: ます。public voidのprocessRequest(のHttpContextコンテキスト) { context.Response.ContentType = "text/plainの"; context.Response.Write( "Hello World"); オブジェクトhtw = new System.Web.UI.Html32TextWriter(context.Response。出力); { typeof(TraceContext) .GetMethod( "Render"、System.Reflection.BindingFlags.NonPublic) .Invoke(HttpContext.Current.Trace、new object [] {htw}); } } エラーが発生しました –
@John Galt - Html32TextWriter *はIDisposable(http://msdn.microsoft.com/en-us/library/system.web.ui.html32textwriter.dispose.aspx)とtypeof標準のC#(http://msdn.microsoft.com/en-us/library/58918ffs(VS.71).aspx)です。すべてのコードをあなたの質問に投稿して(書式設定されているので)、構文をチェックすることができます。 –
こんにちはマーク...ありがとうございました。上記の編集更新をご覧ください。 –