protected void Application_BeginRequest(object sender, EventArgs e)
{
try
{
string isLogRequest = System.Configuration.ConfigurationManager.AppSettings["IsLogRequest"];
if (isLogRequest.Trim() == "false")
{
return;
}
//遍历Post参数
foreach (string key in Request.Form.AllKeys)
{
if (key == "__VIEWSTATE" || key == "__VIEWSTATEGENERATOR" || key == "__EVENTVALIDATION")
{
continue;
}
log.Info(key + ":" + Request.Form[key].ToString());
}
//遍历Get参数。
foreach (string key in this.Request.QueryString.AllKeys)
{
log.Info(key + ":" + Request.QueryString[key].ToString());
}
}
catch (Exception ex)
{
log.Error(ex.StackTrace);
}
}