我试图根据参数sub
在我的控制器中插入标题,但没有成功。我已经试过这两条线,下面的代码:在ASP.NET MVC 4控制器中设置标题
public ActionResult Index(string sub)
{
if (!string.IsNullOrEmpty(sub))
{
HttpContext.Response.Headers.Add("sub", sub);
Response.AddHeader("sub", sub);
}
return View();
}
试试这个HttpContext.Current.Response.AppendHeader( “分”,分);或试试这个HttpContext.Response.AppendHeader(“sub”,sub); –
可能的重复:http://stackoverflow.com/questions/10765725/adding-headers-in-asp-net-mvc-3 – Dima
你想让这个头可以在所有页面中访问吗? –