[英]MVC send data from view to httpcontext class
i tried this but dose not work 我尝试了这个但是没用
@{
HttpContext.Current.Items["key"] = Reservation.ConfirmationFilename;
}
and this is context 这是上下文
public class DownloadFile : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
//here file name is null
string fileName = (string)(HttpContext.Current.Items["key"]);
context.Response.Clear();
context.Response.ContentType = "application/pdf";
context.Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
context.Response.TransmitFile(fileName);
context.Response.End();
}
public bool IsReusable
{
get
{
return false;
}
}
}
the problem is filename
is null after i assign the value to it . 问题是我为它分配值后,
filename
名为null。 any advice to send data from view to httpcontext
任何将数据从视图发送到
httpcontext
您是否尝试过HttpContext.Current.Session["key"]
或TempData["key"]
?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.