过滤器中获取form表单或url请求数据
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
var
httpFormData = filterContext.HttpContext.Request.Form;
var
logContent =
string
.Empty;
//获取url的
logContent = filterContext.HttpContext.Request.QueryString.ToString();
//获取表单的
if
(httpFormData.Count > 0)
{
try
{
var
formDataList = (
from
f
in
httpFormData.AllKeys
select
new
{
name = m,
value = httpFormData[m]
}).ToList();
logContent =
string
.Join(
","
, formDataList);
}
catch
(Exception ef)
{
logContent = filterContext.HttpContext.Server.HtmlEncode(ef.ToString());
}
}
|