开发者

Log all requests (GET, POST, etc.) for all resources (.aspx, .html, .jpg, etc.) to db/file in asp.net

Is it possible to log all requests (GET, POST, etc.) for all resources (.aspx, .html,.pdf, etc.) to db or file in ASP.NET 4 application?

For the开发者_JS百科 moment we use following:

   public class RequestLogger : IHttpModule
   {
      public void Dispose()
      {

      }
      public void Init(HttpApplication context)
      {
         context.PreRequestHandlerExecute += new EventHandler(mPreRequestHandlerExecute);
      }

      void mPreRequestHandlerExecute(object sender, EventArgs e)
      {
         HttpApplication app = sender as HttpApplication;
         StreamReader reader = new StreamReader(app.Request.InputStream);
         System.Diagnostics.Debug.WriteLine(reader.ReadToEnd());
      }
   }

This logger works but only for POST method, in other cases (GET) InputStream length is 0.


Get request do not carry any information other than in url.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜