[Mono-aspnet-list] ScriptService with JSON instead of WebService -- how?

Mike Christensen mike at kitchenpc.com
Mon Nov 26 18:46:00 UTC 2012


Can you check if .asmx is mapped to ScriptHandlerFactory in your web.config?

<add path="*.asmx" verb="*"
type="System.Web.Script.Services.ScriptHandlerFactory,
System.Web.Extensions, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" validate="False" />

On Mon, Nov 26, 2012 at 10:39 AM, Mikko Vuoti <vuoti at iki.fi> wrote:

> ** ** **
>
> I call using jQuery.ajax. I have tried GET and POST, setting
> accepts:’application/json’, dataType:’json’. And all combinations.  The
> service does not seem to honor  accepts-header, but always returns xml.
> All-in-all, ScriptService/ScriptMethod attributes do not seem to have any
> effect. Service description has methods only when WebMethod attribute is
> used.****
>
> ** **
>
> Url points to the service as in ‘/MyService.asmx/Hello?name=Bob’. Adding
> /js to the path produces error.****
>
> ** **
>
> ** **
>
> ** **
>  ------------------------------
>
> *Lähettäjä:* Mike Christensen [mailto:mike at kitchenpc.com]
> *Lähetetty:* 26. marraskuuta 2012 18:09
> *Vastaanottaja:* Mikko Vuoti
> *Kopio:* **mono-aspnet-list at lists.ximian.com**
> *Aihe:* Re: [Mono-aspnet-list] ScriptService with JSON instead of
> WebService -- how?****
>
> ** **
>
> How are you calling your web service?****
>
> ** **
>
> If you go to /YourService.asmx/js - does it generate a JavaScript proxy?**
> **
>
> On Thu, Nov 22, 2012 at 9:17 AM, Mikko Vuoti <vuoti at iki.fi> wrote:****
>
> There seems to be a few questions and answers around on this subject, but
> so far I have not found the missing piece of wisdom to get my script
> service working.****
>
>  ****
>
> I want to create a service to be consumed by a jQuery.Ajax driven
> javascript app. However, I can’t get the method configured so that it would
> return JSON instead of XML.****
>
>  ****
>
> Here is the trivial C#****
>
> ======================****
>
> using System;****
>
> using System.Web;****
>
> using System.Web.Services;****
>
> using System.Web.Script.Services;****
>
>  ****
>
> namespace ScriptServiceTest****
>
> {****
>
>   [ScriptService]****
>
>   public class MyService : WebService****
>
>   {****
>
>     [ScriptMethod]****
>
>     public string Hello(string name)****
>
>     {****
>
>       return("Hello,  " + name);****
>
>     }****
>
>   }****
>
> }****
>
> ======================****
>
> I have added the reference to System.Web.Extensions.****
>
>  ****
>
> I have also generated the web.config (mconfig --target=web af ****AJAX****),
> not sure if this has to do with the problem, though.****
>
>  ****
>
> The code above doesn’t make the service available. If I add
> [WebService]/[WebMethod] attributes to the class/method definition the
> method becomes available as a regular web service, i.e. it returns XML –
> not JSON.****
>
>  ****
>
> I’ve been testing on Mono / .NET 3.5 and 4.0.****
>
>  ****
>
> Any pointer to a resource explaining how script services should be set up
> with mono is warmly welcome!****
>
>  ****
>
>  ****
>
> thanks your time!****
>
>  ****
>
>  ****
>
>  ****
>
>
> _______________________________________________
> Mono-aspnet-list mailing list
> Mono-aspnet-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-aspnet-list****
>
> ** **
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-aspnet-list/attachments/20121126/5b93f557/attachment.html>


More information about the Mono-aspnet-list mailing list