Reputation: 35
I am trying to get datatable search value from view to controller side, but my controller returns an error:
'HttpRequestBase' does not contain a definition for 'Body' and no accessible method 'Body'
This is my code snippet of controller:
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]"]);
}
Upvotes: 0
Views: 2169
Reputation: 2516
Try this code (btw, I don't see how you are using data
variable? but that is not the object of the question)
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]"]);
}
Upvotes: 3