C# と VB.NET の質問掲示板

ASP.NET、C++/CLI、Java 何でもどうぞ

ログ内検索
  • キーワードを複数指定する場合は 半角スペース で区切ってください。
  • 検索条件は、(AND)=[A かつ B] (OR)=[A または B] となっています。
  • [返信]をクリックすると返信ページへ移動します。
キーワード/ 検索条件 /
検索範囲/ 強調表示/ ON (自動リンクOFF)
結果表示件数/ 記事No検索/ ON
大文字と小文字を区別する

No.87870 の関連記事表示

<< 0 >>
■87870  Re[2]: ASPもしくはIISでhttpレスポンスボディを確認する方法
□投稿者/ abc -(2018/07/09(Mon) 13:45:53)
    No87869 (WebSurfer さん) に返信
    ご確認までして頂きありがとうございます。
    現状報告としまして、レスポンスボデイが取得できることは確認できましたが実装で引っ掛かっている状態です。
    
    ・ウェブページは正常に表示されるが、ログ上ではobject movedとなってしまい、以降記録されない
    ・今の方法だとアプリケーションプールが統合モードでしか動かないが、クラシックモードで実現したい(できれば)
    
    ■ログ
    [Request]2018/07/09 13:26:10:
    http://localhost:8888/hoge.aspx
    [Response]2018/07/09 13:26:13:
    (意図する正常なhtml)
    [Request]2018/07/09 13:26:17:
    http://localhost:8888/hoge.aspx
    [Response]2018/07/09 13:26:17:
    <h tml><h ead><t itle>Object moved</t itle></h ead><b ody>
    <h 2>Object moved to <a h ref="hoge.aspx">here</ a>.</h 2>
    </b ody></html>
    [Request]2018/07/09 13:26:17:
    http://localhost:8888/hoge.aspx
    [Response]2018/07/09 13:26:17:
    (以降記録されず……)
    
    ■ソース
    ※OutputFilterStreamはご紹介頂いた下記URLのものをコピペしています。
    https://stackoverflow.com/questions/1038466/logging-raw-http-request-response-in-asp-net-mvc-iis7#
    
    public class Logger : IHttpModule
        {
         static readonly string responseLogPath = @"D:\test.txt";
         OutputFilterStream filter;
    
         public void Init(HttpApplication application)
         {
             application.BeginRequest += (new EventHandler(this.Application_BeginRequest));
             application.EndRequest += (new EventHandler(this.Application_EndRequest));
         }
    
         public void Dispose()
         {
         }
    
         private void Application_BeginRequest(Object sender, EventArgs e)
         {
             HttpResponse response = HttpContext.Current.Response;
             WriteLog("[Request]" + DateTime.Now + ":" + Environment.NewLine + HttpContext.Current.Request.Url.ToString());
    
             filter = new OutputFilterStream(response.Filter);
             response.Filter = filter;
         }
    
         private void Application_EndRequest(object sender, EventArgs e)
         {
             WriteLog("[Response]" + DateTime.Now + ":" + Environment.NewLine + filter.ReadStream());
         }
    
         private void WriteLog(string log)
         {
             using (var sw = new StreamWriter(responseLogPath, true))
             {
                 sw.WriteLine(log);
             }
         }
    }
    
    
記事No.87867 のレス /過去ログ151より / 関連記事表示
削除チェック/



<< 0 >>

パスワード/

- Child Tree -