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

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Download File Routine problem in custom module on production serverDownload File Routine problem in custom module on production server
Previous
 
Next
New Post
8/23/2007 3:30 AM
 

I am having a big problem downloading a file from my custom DNN Dynamic Module. From within the following Button Click server-side event, I run the following code. The dowload code works perfectly on my development PC but fails on the production server. I run Windows XP, VS2005, CLR 2.0, DNN 441, IIS6, IE7. I am not sure if it matters but my production server runs as Https:

 

----- Code Begins ---------

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

 

Dim s As String = String.Empty

Dim sFilename As String = String.Empty

 

sFilename = "TRVBilling_All_" & wcDateRange.DataValue.ToString & ".csv"

 

File.Delete("C:\Program Files\CoreBillingTempDir\" & sFilename)

Dim sw As StreamWriter = File.CreateText("C:\Program Files\CoreBillingTempDir\" & sFilename)

 

Dim _dt As DataTable = CType(Session("GetTRVBilling_CurrentDataSet"), DataSet).Tables(_intTable)

 

For Each col As DataColumn In _dt.Columns

    s = s + col.ColumnName + ","

Next

sw.WriteLine(s.TrimEnd(","c))

s = ""

 

For Each row As DataRow In _dt.Rows

    For Each col As DataColumn In _dt.Columns

        s = s + row(col.ColumnName).ToString + ","

    Next

    sw.WriteLine(s.TrimEnd(","c))

    s = ""

Next

 

'sw.Flush()

sw.Close()

 

Dim _checkFile As FileInfo

 

_checkFile = New FileInfo("C:\Program Files\CoreBillingTempDir\" & sFilename)

 

If _checkFile.Exists Then

Dim fs As New FileStream("C:\Program Files\CoreBillingTempDir\" & sFilename, FileMode.Open, FileAccess.Read)

 

Dim length As Integer = Convert.ToInt32(fs.Length)

Dim byteBuffer(length) As Byte

fs.Read(byteBuffer, 0, length)

 

With Page.Response

     .Clear()

     .ContentType = "text/csv"

     .AddHeader("content-disposition", "attachment; filename=" & sFilename) ' Forces the file download

     .AddHeader("Content-Length", length.ToString())

     .AddHeader("Accept-Ranges", "bytes")

     .AddHeader("Accept-Header", length.ToString())

     .OutputStream.Write(byteBuffer, 0, length)

     .Flush()

     HttpContext.Current.ApplicationInstance.CompleteRequest() ' This replace .End() which cause a Threading exception

End With

End If

End Sub

----- Code Ends -----------

The normal File Download dialog box opens (correctly!) on my development pc (gives the user the chance to either Open Save Cancel) and the subsequent file download works perfectly (Btw, I am downloading .Csv type files and I did exclude the mime type (text/csv) in the compression config file). On my production server, when I run the above code, I get a dialog the comes up for a few seconds and indicates that the code is trying to download Default.aspx from my production web site: www.ncstrvprocessing.com. Eventually this times out and an error comes up and says: "Internet Explorer cannot download Default.aspx from www.ncstrvprocessing.com. Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later." Any Help is greatly appreciated!!

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Download File Routine problem in custom module on production serverDownload File Routine problem in custom module on production server


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