如何返回XML字符串作为一个动作导致MVC [英] How to return an XML string as an action result in MVC

查看:226
本文介绍了如何返回XML字符串作为一个动作导致MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/134905/what-is-the-best-way-to-return-xml-from-a-controllers-action-in-asp-net-mvc">What是从ASP.NET MVC控制器的行动返回XML的最佳方式是什么?

我能够返回JSON和局部视图(HTML)作为有效的ActionResult,而是如何将一个返回的XML字符串?

I'm able to return JSON and partial views (html) as a valid ActionResult, but how would one return an XML string?

推荐答案

您可以使用返回this.Content(的xmlString,为text / xml); 返回从操作建XML字符串。

You could use return this.Content(xmlString, "text/xml"); to return a built XML string from an action.

这篇关于如何返回XML字符串作为一个动作导致MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆