您的位置:首页 > 产品设计 > UI/UE

在Global.asax文件的Application_BeginRequest中获取request请求内容

2018-03-22 15:24 501 查看

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);
}

}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐