JSON return error with ASP

后端 未结 1 1138
梦毁少年i
梦毁少年i 2021-01-11 21:22

We are using a ASP app written by an outside vendor. I am tasked with making a small change to the app however I don\'t know anything about asp or json. Through some resea

相关标签:
1条回答
  • 2021-01-11 21:57

    Json in ApiController with two parameters has a signature of,

    protected internal JsonResult<T> Json<T>(
    T content,
    JsonSerializerSettings serializerSettings
    )
    

    Json in Controller with two parameters has a signature of,

    protected internal JsonResult Json(
    object data,
    JsonRequestBehavior behavior
    )
    

    getipaddressController inherited from ApiController, but you used Controller method Json. Use,

    return new JsonResult()
    {
     Data = ipAddress,
     JsonRequestBehavior = JsonRequestBehavior.AllowGet
    };
    

    If you still want the behavior.

    0 讨论(0)
提交回复
热议问题