我试图从视图到控制器端获取数据表搜索值,但我的控制器返回错误:
'HttpRequestBase'不包含'Body'的定义,也没有可访问的方法'Body'
这是我的控制器代码段:
public ActionResult EditCustomer(int id)
{
string requestData = "";
using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
{
requestData = reader.ReadToEnd();
}
NameValueCollection data = HttpUtility.ParseQueryString(requestData);
string Search = Convert.ToString(Request["search[value]"]);
}
答案 0 :(得分:1)
尝试以下代码(顺便说一句,我看不到您如何使用data
变量?但这不是问题的对象)
public ActionResult EditCustomer(int id)
{
string requestData = "";
using (Stream iStream = Request.InputStream)
{
using (StreamReader reader = new StreamReader(iStream, Encoding.UTF8)) //you should use Request.ContentEncoding
{
requestData = reader.ReadToEnd();
}
}
NameValueCollection data = HttpUtility.ParseQueryString(requestData);
string Search = Convert.ToString(Request["search[value]"]);
}