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 是什么?
基础教程推荐
- Moq It.Is<>不匹配 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
