locked
ashx handler output a generic list as xml RRS feed

  • Question

  • User-146144241 posted

    I am trying to output my generic list as an xml document.  I can serialize my list and view the output as an xml document in firefox, but in ie, I get an error "The XML page cannot be displayed Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later."  Also, I was using a jquery plugin to read my xml file and I can't get it to work.  Can someone please show me how to output a generic list via a ashx handler?

     

    List<Brokerage> brokerageList = BrokerageController.GetBrokerages();

    StringWriter outStream = new StringWriter();

    XmlSerializer xmlSerializer = new XmlSerializer(brokerageList.GetType());

    xmlSerializer.Serialize(outStream, brokerageList);

    context.Response.ClearHeaders();

    context.Response.Clear();

    context.Response.Write(outStream);

    This will do something, but it isn't correct.  I can view it in firefox, but something is definitely wrong.

    Friday, August 26, 2011 10:26 AM

Answers