one*_*end 3 asp.net asp.net-mvc webforms response.write
这很简单但是
在asp net MVC中使用经典webforms"response.write"的最佳方法是什么?特别是mvc5.
让我们说:我只想写一个简单的字符串来控制器屏幕.
在mvc中是否存在response.write?
谢谢.
如果方法的返回类型是a ActionResult,则可以使用该Content方法返回任何类型的内容.
public ActionResult MyCustomString()
{
return Content("YourStringHere");
}
Run Code Online (Sandbox Code Playgroud)
或者干脆
public String MyCustomString()
{
return "YourStringHere";
}
Run Code Online (Sandbox Code Playgroud)
Content方法允许您返回其他内容类型,只需将内容类型作为第二个参数传递.
return Content("<root>Item</root>","application/xml");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12014 次 |
| 最近记录: |