what is response.write in asp.net mvc?(asp.net mvc 中的 response.write 是什么?)
问题描述
这会很简单,但是
在 asp net MVC 中使用经典网络表单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 是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:asp.net mvc 中的 response.write 是什么?
基础教程推荐
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
