SORU
17 EKİM 2008, Cuma


Nasıl ASMX dosya çıktı JSON izin

Dosya arkasında bir kod ile ASMX dosyası oluşturdum. İyi çalışıyor, ama XML çıktısı.

Ancak, çıkış JSON için ona ihtiyacım var. ResponseFormat yapılandırma işe yaramıyor. Kod-arkasında benim

[System.Web.Script.Services.ScriptService]
public class _default : System.Web.Services.WebService {
    [WebMethod]
    [ScriptMethod(UseHttpGet = true,ResponseFormat = ResponseFormat.Json)]
    public string[] UserDetails()
    {
        return new string[] { "abc", "def" };
    }
}

CEVAP
22 Kasım 2012, PERŞEMBE


Al bir saf JSON dize, çevirmeden sarılmış bir XML, yazmayı unutma JSON dize doğrudan HttpResponse ve değişim WebMethod dönüş türü için void.

    [System.Web.Script.Services.ScriptService]
    public class WebServiceClass : System.Web.Services.WebService {
        [WebMethod]
        public void WebMethodName()
        {
            HttpContext.Current.Response.Write("{property: value}");
        }
    }

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Alexander Johnson

    Alexander Jo

    26 Temmuz 2008
  • LaKe Lightroom Tutorials

    LaKe Lightro

    22 Temmuz 2014
  • Sarah's YouTube Channel

    Sarah's YouT

    27 Temmuz 2009