So geben Sie JSON mit ASP.NET & jQuery zurück

Ich kann nicht herausfinden, wie ich mit meinem Code JSON-Daten zurückgeben kann.

JS

$(function () {
$.ajax({
        type: "POST",
        url: "Default.aspx/GetProducts",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            // How to return data here like a table???  
            $("#Second").text(msg.d);
            //alert(msg.d);
        }
    }); 
});

C # von Default.aspx.cs

[WebMethod]
public static string GetProducts()
{
   var products  = context.GetProducts().ToList();   
   return What do I have to return ????
}

Danke im Voraus!

Antworten auf die Frage(5)

Ihre Antwort auf die Frage