0

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 . any advice to send data from view to httpcontext

  • executed when button click to download file –  Oct 25 '17 at 12:18
  • The answer on this possible duplicate will help... [HttpContext.Current.Items\["value"\] not working because AngularJS calls create new sessions](https://stackoverflow.com/questions/31814034/httpcontext-current-itemsvalue-not-working-because-angularjs-calls-create-ne) –  Oct 25 '17 at 13:29

1 Answers1

0

Did you try HttpContext.Current.Session["key"] or TempData["key"] ?

Murat Gündeş
  • 852
  • 2
  • 17
  • 31