The following is an example how i am posting data to a controller action in MVC.The data is perfectly populating to my model object and working fine.
var data={};
data.SearchText = 'abc'
data.SearchText1 = 'abcd'
var contentType = 'application/json; charset=utf-8';
$.ajax({
type: 'POST',
cache: false,
contentType: contentType,
url: User/_UserList,
data: JSON.stringify(data),
success: successHandlerFunction,
complete: completeHandlerFunction
});
[HttpPost]
public JsonResult _UserList(SearchViewModel model)
{
var users= "" ; //Get Data from DB ;
return Json(users, JsonRequestBehavior.AllowGet);
}
But in case of an exception i am trying to fetch value of model
public void OnException(ExceptionContext filterContext)
{
//filterContext.HttpContext.Request.Form -- is not giving any value
//filterContext.HttpContext.Request.QueryString -- is also having no value
//filterContext.HttpContext.Request.Params -- also no value about model
}
Can anybody give me a clue why the above piece of code not working