Wel*_*lli 3 asp.net controller asp.net-mvc-4
我试图根据参数在我的控制器中插入一个标题sub,但没有成功.我试过这两行,这里是代码:
public ActionResult Index(string sub)
{
if (!string.IsNullOrEmpty(sub))
{
HttpContext.Response.Headers.Add("sub", sub);
Response.AddHeader("sub", sub);
}
return View();
}
Run Code Online (Sandbox Code Playgroud)
这可能对你有用..
public ActionResult Index(string sub)
{
if (!string.IsNullOrEmpty(sub))
{
HttpContext.Response.AppendHeader("sub", sub);
}
return View();
}
Run Code Online (Sandbox Code Playgroud)