1

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.

2
  • 2
    I would switch host if I were you ;) there are plenty (even cheap ones) that do allow it. Commented Mar 4, 2011 at 15:23
  • Not really my choice I'm afraid, that is up to the client, can only recommend. Don't suppose there is a list of ones that do support reflection (you would never know from the current host's website that the service was in any way restricted). Commented Mar 4, 2011 at 15:26

1 Answer 1

1

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));
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.