[英]asp.net webforms - how to get the json data of a javascript function using c#
[英]How to get data from server in JSON format by using ASP.NET c#?
如何使用ASP.NET c#從服務器獲取JSON格式的數據?
我知道如何使用php獲取JSON格式的數據,但是我正在嘗試使用c#進行相同的操作。
從服務器端發布JSON時,請考慮以下事項:
數據:JSON.stringify(person),
contentType:“應用程序/ json”
在您的客戶端上:
從HttpCurrent.Context.Request.InputStream獲取請求主體。
讀取輸入流並轉換為字符串
反序列化json對象
像這樣做::
string json;
using(var reader = new StreamReader(Request.InputStream)){
json = reader.ReadToEnd();
}
var person = Json.Decode(json);
教程: http : //www.mikesdotnetting.com/article/220/posting-data-with-jquery-ajax-in-asp-net-razor-web-pages
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.