我有以下 Ajax.actionlink,它将执行操作方法并返回 JSON:-
@Ajax.ActionLink("Start Process", "StartProcess", "Home",
new { name = "BuisnessProcess" },
new AjaxOptions
{ HttpMethod = "POST",
LoadingElementId = "tobehide2",
UpdateTargetId = "startprocess",
OnSuccess = "Animate" })
</div> <img id="tobehide2" src="~/Content/ajax-loading2.gif" />
目前,当用户单击链接时,它将在浏览器中显示 JSON 信息:-
{"activityId":"2119_666_BuisnessProcess_process1_setverialbe","processId":"666_BuisnessProcess_process1"}
但我想做的是基于返回的 Json 构建另一个 Ajax.actionlink,并将其activityId
作为新参数传递给 Ajax.actionlink。
此致
:::更新:::
[HttpPost]
public ActionResult StartProcess(string name)
{
using (var client = new WebClient())
{
try
{
var query = HttpUtility.ParseQueryString(string.Empty);
query["j_username"] = "kermit";
query["hash"] = "9449B5ABCFA9AFDA36B801351ED3DF66";
query["loginAs"] = User.Identity.Name;
query["imagurl"] = "123";
var url = new UriBuilder("http://localhost:8080/jw/web/json/workflow/process/start/" + name.ToString() + ":28:process1");
url.Query = query.ToString();
string json = client.DownloadString(url.ToString());
Thread.Sleep(500);
return Content("Process started succsfully. Returned values are :-" + json);
}
catch (System.Net.WebException ex)
{
return Content("", "application/json");
}
}
}