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...

Amit MohantyRank #112 · 20K reputationPosted Sep 22, 2019, 10:05 PM EDT
Karan Thakkar186 reputationPosted Sep 22, 2019, 10:48 PM EDT
Karan Thakkar186 reputationPosted Sep 22, 2019, 10:33 PM EDT
Jaimin ShethiyaRank #177 · 13.7K reputationPosted Sep 23, 2019, 5:06 AM EDT
You have written in MVC C# method is GET and Ajax call you have method type is POST so that is not correct first you have correct that one and please make sure this type of the mistake in future.
can you please try the above code.
let me know if you have needed anything from side.
Thanks