开发者

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

开发者 https://www.devze.com 2023-02-08 06:54 出处:网络
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?

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

精彩评论

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