[Mono-bugs] [Bug 525589] New: JavaScriptConverter registered in web.config is not used
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Mon Jul 27 11:24:25 EDT 2009
http://bugzilla.novell.com/show_bug.cgi?id=525589
Summary: JavaScriptConverter registered in web.config is not
used
Classification: Mono
Product: Mono: Class Libraries
Version: 2.4.x
Platform: x86
OS/Version: Windows XP
Status: NEW
Severity: Normal
Priority: P5 - None
Component: Sys.Web.Services
AssignedTo: atsushi at ximian.com
ReportedBy: cheburator2 at gmail.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Created an attachment (id=308140)
--> (http://bugzilla.novell.com/attachment.cgi?id=308140)
Sample web site to help debug a problem
User-Agent: Opera/9.64 (Windows NT 5.1; U; en-GB) Presto/2.1.1
Web Service doesn't use JavaScriptConverter that is declared in web.config. My
web.config has following lines:
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization>
<converters>
<add name="MyRecord2JSON" type="Nostr.Record2JSON"/>
</converters>
</jsonSerialization>
</webServices>
</scripting>
</system.web.extensions>
But Nostr.Record2JSON is not used for encoding/decoding web service method
results and arguments.
Reproducible: Always
Steps to Reproduce:
1. Unpack attached archive.
2. Run XSP in the WebSite2 folder.
3. Navigate to http://localhost:8080/
4. Press "Call me" button.
5. Analyze text in textarea
Actual Results:
[{"Table":"Glossary","ID":"1","Code":"NoVSomeGloss"},{"Name":"Derived","Table":"GlossView","ID":"2","Code":"NoVAll"},{"Table":"Glossary","ID":"3","Code":"NoVQ"}]
Expected Results:
Results from .NET:
[{"__type":"Nostr.Record","CustomConverter":"Is
usedGlossary"},{"CustomConverter":"Is
usedGlossView"},{"__type":"Nostr.Record","CustomConverter":"Is usedGlossary"}]
There is no workaround. Please fix ASAP.
P.S. To save you time, I've dug into Mono sources (138126) and found the
following code in JavaScriptSerializer class:
public JavaScriptSerializer (JavaScriptTypeResolver resolver)
{
_typeResolver = resolver;
ScriptingJsonSerializationSection section =
(ScriptingJsonSerializationSection) ConfigurationManager.GetSection
("system.web.extensions/scripting/webServices/jsonSerialization");
if (section == null) {
_maxJsonLength = 102400;
_recursionLimit = 100;
}
else {
_maxJsonLength = section.MaxJsonLength;
_recursionLimit = section.RecursionLimit;
}
}
As you can see, call to RegisterConverters(section.Converters) is suspiciously
missing. The easy way to fix it would be to add it. But from theoretical point
of view there could be some application that explicitly uses
JavaScriptSerializer but doesn't need any converters from web.config. That
application would work in .NET (it doesn't add any converters in
JavaScriptSerializer constructor), but would fail in Mono. In order to make it
work all references to ConfigurationManager should be removed from
JavaScriptSerializer constructor. Instead, there should be a static method that
would construct JavaScriptSerializer and initialize it from web.config. It
should be used to construct JavaScriptSerializer inside
System.Web.Extensions.dll instead of regular constructor. Hope this helps.
--
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
More information about the mono-bugs
mailing list