Does ASP.NET MVC's JsonResult use reflection
Does ASP.NET MVC's JsonResult use reflection to work out what Json to return ?
I'm asking the开发者_运维问答 question because on the particular project I'm working on at the moment I've already run into problems with reflection. The hosting provider I'm having to use doesn't allow reflection and so I had to rewrite alot of code that was making use of AutoMapper which uses reflection.
Does ASP.NET MVC's JsonResult use reflection to work out what Json to return
It uses the JavaScriptSerializer class which in turns uses reflection to cycle through the properties of model. Excerpt from it's ExecuteResult method:
...
if (this.Data != null)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
response.Write(serializer.Serialize(this.Data));
}
精彩评论