在 Global.asax中:

protected void Application_BeginRequest(object sender, EventArgs e)
        {
            Common.Log log = new Common.Log();
            try
            {
                if (bool.Parse(ConfigurationManager.AppSettings["request_log"]))
                {
                    if (this.Request != null && this.Request.Form != null && this.Request.Form.AllKeys.Length > 0)
                    {
                        StringBuilder requestParam = new StringBuilder(this.Request.Url.AbsoluteUri + "\t");
                        foreach (var item in this.Request.Form.AllKeys)
                        {
                            requestParam.AppendFormat("{0}={1}&", item, this.Request.Form[item]);
                        }
                        log.addLog(string.Format("【{0}】{1}", this.Request.UserHostAddress, requestParam.ToString().Remove(requestParam.Length - 1, 1)));
                    }
                }
            }
            catch (Exception ex)
            {
                log.addLog(ex);
            }
        }

 

posted on 2016-04-13 10:06  OriginalCobra  阅读(413)  评论(0编辑  收藏  举报