我有一个返回 json 的处理程序
public void ProcessRequest (HttpContext context) {
HttpResponse response = context.Response;
response.ContentType = "application/json";
string controlType = context.Request.QueryString["controlType"];
JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
CmsManager cmsManager = new CmsManager();
IDictionary<string, Guid> sitefinityPageDictionary = SitefinityUtilities.sitefinityPageDictionary;
if (string.IsNullOrEmpty(controlType)) {
response.Write("0");
}
else {
var pagesWithControl = from page in sitefinityPageDictionary
from control in cmsManager.GetPage(page.Value).Controls
where control.TypeName == controlType
select page;
response.Write(jsonSerializer.Serialize(pagesWithControl));
}
}
在一个单独的项目中,我想向处理程序发出请求以使用返回的 json 对象。
HttpRequest
将是用于向处理程序发出请求的适当对象吗?- 有人可以提供一个简单的例子来说明如何从另一个 c# 类(不是 javascript)请求和使用 json 对象吗?