Karan Thakkar

Karan Thakkar

  • NA
  • 203
  • 85.5k

How call controller Action result with Ajax in Mvc?

Sep 23 2019 1:37 AM
I want to call controller ActionResult from an ajax call which has one string paramenter.
 
like this
 
[HttpGet]
[Route("AreaName/ControllerName/MethodName/{filePath}")]
public ActionResult DeleteFile(string filePath) {
return Json(string.Empty, JsonRequestBehavior.AllowGet);
}
--Ajax call in jquery looks like this. when I am passing filePath without any special character ActionResult gets called but not when I pass below string.
var filePath='/OnlineFdDocument/200//UIDAI-Aadhar-Card-Updates-2-644x362.jpg'
$.ajax({
url: "/AreaName/Document/DeleteFile/" + filePath,
dataType: "json",
type: "Post",
contentType: 'application/json; charset=utf-8',
data: { "docUrl": docUrl },
success: function (data) {
},
 
If anyone can help me out the please reply.
Thank You...

Answers (4)