Passing IDictionary object to Web service
-
31-10-2019 - |
Question
In my asmx file, I have
[WebMethod]
[ScriptMethod]
public void Method(IDictionary<string, CustomClass> objectOfCustomClass)
{
//do stuff
}
custom class is defined as:
public class CustomClass
{
public string Prop1 { get; set; }
public string Prop2 { get; set; }
}
All goes well and the web service is being successfully consumed from Jquery ajax method. Recently I decided to test and try and access it from the direct URL such as http://localhost/Services.asmx/Method
and I get this message
"Cannot serialize interface System.Collections.Generic.IDictionary"
This seems off. What's causing it and is it normal? I am confused - it seems like the clean way of doing things but according to Microsoft shouldn't be done, yet it works, only not when accessing the web service directly. What gives? I also read on some MS sites that you can't pass IDictionary to the web service as a parameter yet it works fine...SO can it be done or not? Can someone clarify this once and for all?
No correct solution