在asp.net-core-2.1
Controllerbase中没有
Json(Object)方法。但是
Controller确实如此。
因此,要么将当前控制器重构为
Controller
public class GraficResourcesApiController : Controller { //...}
可以访问该
Controller.Json方法,或者您可以
JsonResult在 *** 作中初始化一个新的自己
return new JsonResult(rows);
这基本上是该方法在内部执行的 *** 作
Controller
/// <summary>/// Creates a <see cref="JsonResult"/> object that serializes the specified <paramref name="data"/> object/// to JSON./// </summary>/// <param name="data">The object to serialize.</param>/// <returns>The created <see cref="JsonResult"/> that serializes the specified <paramref name="data"/>/// to JSON format for the response.</returns>[NonAction]public virtual JsonResult Json(object data){ return new JsonResult(data);}/// <summary>/// Creates a <see cref="JsonResult"/> object that serializes the specified <paramref name="data"/> object/// to JSON./// </summary>/// <param name="data">The object to serialize.</param>/// <param name="serializerSettings">The <see cref="JsonSerializerSettings"/> to be used by/// the formatter.</param>/// <returns>The created <see cref="JsonResult"/> that serializes the specified <paramref name="data"/>/// as JSON format for the response.</returns>/// <remarks>Callers should cache an instance of <see cref="JsonSerializerSettings"/> to avoid/// recreating cached data with each call.</remarks>[NonAction]public virtual JsonResult Json(object data, JsonSerializerSettings serializerSettings){ if (serializerSettings == null) { throw new ArgumentNullException(nameof(serializerSettings)); } return new JsonResult(data, serializerSettings);}
资源
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)