[Mono-aspnet-list] [WebMethod] behavior changed between 2.4.3 and 2.6.1

jmalcolm malcolm.justin at gmail.com
Tue Feb 2 13:17:23 EST 2010


Take the following C# code:

[WebMethod]
public static object GetCityStateByZip(string zip)
{
     return new { City = "Seattle", State = "WA" };
}

Ignore the uselessness and the unused 'zip' parameter.  When invoked by a
client (eg. from .ajax() in JQuery) this WebMethod should generate a JSON
response.

On Mono 2.4.3 it returns the following JSON string:

{"d":{"City":"Seattle","State":"WA"}}

On Mono 2.6.1 it leaves off the 'd' wrapper:

{"City":"Seattle","State":"WA"}

Does anybody know if this change was intentional or what the rational may
have been?

The change breaks any client-side code that parses the JSON and expects to
see the 'd'.  It also opens the door to some cross site scripting attacks.

http://encosia.com/2009/02/10/a-breaking-change-between-versions-of-aspnet-ajax/

I think it may be a bug/regression as .NET 2.0 worked the way Mono 2.6.1
does now while Mono 2.4.3 was compatible with the behavior in .NET 3.5 but I
thought I would post here first in case this is an intentional change.

Thanks.

Justin
-- 
View this message in context: http://old.nabble.com/-WebMethod--behavior-changed-between-2.4.3-and-2.6.1-tp27424989p27424989.html
Sent from the Mono - ASP.NET mailing list archive at Nabble.com.



More information about the Mono-aspnet-list mailing list