![](/img/trans.png)
[英]How to set Content-Type for a Redirect in ASP.NET Core MVC controller
[英]How to set Content-Type to exactly “text/plain” on ASP.NET MVC?
編碼
public class HomeController : Controller
{
public ActionResult Index()
{
return Content("hello", "text/plain");
}
}
正在響應 header
Content-Type: text/plain; charset=utf-8
我的問題是如何從響應 header Content-Type 中刪除“; charset=utf-8”?
在這里如何從 ASP.NET Core MVC 響應中的 Content-Type 中刪除字符集? 這是如何在 asp.net 內核上執行此操作的。
您可以在Content()
之前清除Charset
public ActionResult Index()
{
Response.Charset = "";
return Content("hello", "text/plain");
}
請試試這個。
public ActionResult Index()
{
Response.ContentType = "text/plain";
return Content("your content");
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.