none
File() function to download PDF or XLSX File , didn't show as file is being downloading in Chrome bowser RRS feed

  • Question

  • Hi All,

    I have create an Action Method in .Net Core 2.1 to download the PDF or XlsX file in local download directory ,  the PDF/XLSX file is downloading but its not show in browser as traditional file downloading works, it just download the file in "Downloads" directory invisibly from user. My Source is as below:

                             

    public ActionResult GetProductFamilyPurchaseWithGrandTotal(string ProductFamily, string CustomerGroup, string fileName)
            {           
                ProductFamilyPurchaseModel productFamilyPurchaseModel = new ProductFamilyPurchaseModel();
                productFamilyPurchaseModel.ProductFamily = ProductFamily;
                productFamilyPurchaseModel.CustomerName = CustomerGroup;


                var memoryStream = _IProductFamilyPurchaseServices.ProductFamilyPurchaseExportPdf(productFamilyPurchaseModel, fileName);
                if (memoryStream.CanSeek)
                    memoryStream.Seek(0, SeekOrigin.Begin);

               return File(memoryStream, Common.GetContentType(fileName),Path.GetFileName(fileName));
             ///   return new  FileStreamResult(memoryStream, Common.GetContentType(fileName));
            }


      I have tried multiple way that i can , but i didn't get success, Please help me out prof this issue.

    Thanks


    • Moved by CoolDadTx Monday, June 17, 2019 1:43 PM ASP.NET related
    Friday, June 14, 2019 6:07 PM

All replies

  • Hi FantaManta,

    Thank you for posting here.

    From your description, your issue is more related about ASP.NET. So it will be more appropriate to ask your question at ASP.NET Forums.

    The C# forum is for C# related question, we discuss and ask the C# programming language, IDE, libraries, samples and tools here.

    Thank you for your understanding.

    Best Regards, 
    Xingyu Zhao

    Monday, June 17, 2019 7:28 AM