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 是什么?
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 输入按键事件处理程序 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 如何用自己压缩一个 IEnumerable 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
