I have a class called CodeWithMessage that I need to return as a json object from my web service.
Here is how the class is defined:
namespace UserSite //Classes For my site
{
namespace General
{
public class CodeWithMessage
{
private int iCode = 0;
private string sMessage = "";
public CodeWithMessage(int Code, string Message)
{
iCode = Code;
sMessage = Message;
}
public CodeWithMessage()
{
}
public void Message(string lMessage)
{
sMessage = lMessage;
}
public void Code(int lCode)
{
iCode = lCode;
}
}
Within the web service, I have the following method:
[WebMethod(Description = "Creates A New Blog.")]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public CodeWithMessage AddNewBlog(string sTitle, string sDescription, string sOohrl, int iCategory=30)
{
CodeWithMessage CWM;
CWM = new CodeWithMessage();
CWM.Message("That url Is In Use");
CWM.Code(0);
return CWM;
After making the call, I am expecting a json object with the values, but instead, I am receiving this response:
{"d":{"__type":"UserSite.General.CodeWithMessage"}}
I am confused as to why I am not getting the actual json object with values. I thought asp.net would handle serialization automatically. Is that not the case?
Thank you for your help.