我想通过angularjs将路径url作为参数传递给我的asp.net mvc控制器方法。 当我调试时,我发现代码中的Path参数缺少斜杠。AngularJs传递url作为参数
等代替 “d:\ MYDIR \ LIST.TXT” 它显示 “d:MyDirList.txt”
我如何能够通过URL作为参数的角度?
public JsonResult GetData(string Path)
{
var details = GetResult(Path);
return Json(details, JsonRequestBehavior.AllowGet);
}
VAR ListPath = “d:\ MYDIR \ LIST.TXT”;
$http.get("/Home/GetData",
{ params: { "Path": ListPath })
.then(function (response) {
console.log(response);
});
我认为在发送之前,你应该使用编码encodeURIComponent方法() –
这个路径,请看看例子http://stackoverflow.com/questions/16630471/how-can-i-invoke-encodeuricomponent-from-angularjs-template –