Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...Can you download documents from a Custom Module?Can you download documents from a Custom Module?
Previous
 
Next
New Post
12/17/2012 8:34 AM
 

Hi,

I have created a custom module for my client. This module is more of a reporting module. It has a few dropdown lists at the top to filter data that is returned below. All of this works fine but for each record that is returned, I display a hyperlink for a .pdf document that is associated to this record. This document is stored in the database and when I click on the link, nothing happens.

The code that I'm using to retrieve the document from the database works fine in another web app that I've created for this client but that web app is not a DNN site. Here is the code I use to retrieve the document:

  public static bool openDocument(int iDocID, int languageID)
        {
            using (var ctx = Components.Data.Model.ArchivesModel.Instance())
            {
                var doc = from d in ctx.DocumentLanguages.Include("Document").Where(dd => dd.DocumentID == iDocID && dd.LanguageID == languageID)
                          select d;

                var document = doc.FirstOrDefault();

                HttpContext.Current.Response.Buffer = false;
                HttpContext.Current.Response.Clear();
                if (document.Document.FileSize > 0)
                {
                    string strFileName = document.Document.FileName;
                    HttpContext.Current.Response.ContentType = document.Document.ContentType;
                    HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + strFileName.ToString());
                    HttpContext.Current.Response.OutputStream.Write(document.FileContent, 0, ((int)document.Document.FileSize));

                    if (HttpContext.Current.Response.IsClientConnected)
                    {
                        HttpContext.Current.Response.Flush();
                        HttpContext.Current.Response.Close();
                        HttpContext.Current.Response.End();

                        return true;
                    }
                }
                return false;
            }
        }

This code is called upon the click of the link and works fine in the other application but does nothing in my dnn module. Can you open up a document in DNN this way? If not, is there a better way of doing this?

Thanks

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...Can you download documents from a Custom Module?Can you download documents from a Custom Module?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out