在MVC中,如何返回字符串结果?

在MVC中,如何返回字符串结果?,第1张

在MVC中,如何返回字符串结果?

您可以使用

ContentResult
返回一个纯字符串

public ActionResult Temp() {    return Content("Hi there!");}

ContentResult
默认情况下返回a
text/plain
作为其contentType。这是可重载的,因此您还可以执行以下 *** 作:

return Content("<xml>This is poorly formatted xml.</xml>", "text/xml");


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5088746.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-16
下一篇 2022-11-17

发表评论

登录后才能评论

评论列表(0条)

保存