什么是asp.net MVC中的response.write? [英] what is response.write in asp.net mvc?
本文介绍了什么是asp.net MVC中的response.write?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这将非常简单,但是
在ASP.NET MVC中使用经典Web表单"response.write"的最佳方法是什么.尤其是mvc5.
What is the best way of using classical webforms "response.write" in asp net MVC. Especially mvc5.
让我们说:我只想编写一个简单的字符串从控制器屏幕显示.
Let's say: I just would like to write a simple string to screen from controller.
mvc中是否存在response.write?
Does response.write exist in mvc?
谢谢.
推荐答案
如果方法的返回类型为ActionResult
,则可以使用Content
方法返回任何类型的内容.
If the return type of your method is an ActionResult
, You can use the Content
method to return any type of content.
public ActionResult MyCustomString()
{
return Content("YourStringHere");
}
或者简单地
public String MyCustomString()
{
return "YourStringHere";
}
内容方法还允许您返回其他内容类型,只需将内容类型作为第二个参数传递即可.
Content method allows you return other content type as well, Just pass the content type as second param.
return Content("<root>Item</root>","application/xml");
这篇关于什么是asp.net MVC中的response.write?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文