Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4070226
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:36:02+00:00 2026-05-20T16:36:02+00:00

I’m converting a bunch of FOXPRO / FOXWEB apps to ASP.NET. The underlying DB

  • 0

I’m converting a bunch of FOXPRO / FOXWEB apps to ASP.NET.

The underlying DB is still foxpro (for the moment).

I am passing a table to some VB.NET code that I want to have converted to a CSV file and sent back to the client for download. And it works! Sort of … It works sometimes, but at other times, instead of asking me if I want to download the CSV file, it just spews the file to the browser window.

On the asp side, I am passing the response object, the table and the csv file name.

<%
   Dim xls_fn As String = "test01.csv"

   'OLEDB call to fill up 'tbl' ... this works.

   sendTableAsCSVtoClient(response, tbl, xls_fn)
%>

In the file clsCommon.vb, I have the following code:

Option Explicit On 
'Option Strict On

Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.Page
Imports System.IO
Imports Microsoft.VisualBasic
Imports System.Diagnostics
Imports System.Data
Imports System.Data.OleDb


Public Class clsCommon
    Inherits Page

    Public Shared Function enq(ByVal str As String) As String
        Dim dq As String
        dq = """"
        Return dq & str & dq
    End Function

    ' some other functions and subs defined in here ... blah blah blah
    ' ...

    Public Shared Function sendTableAsCSVtoClient(ByVal resp As HttpResponse, ByVal sqlTable As DataTable, ByVal xls_fn As String) As Boolean
        Dim r As DataRow
        Dim c As DataColumn
        Dim sep As String = ","
        Dim FileExtension As String
        Dim lcFileNameONLY As String
        Dim i As Integer
        Dim dq As String = """"

        FileExtension = UCase(Path.GetExtension(xls_fn))
        lcFileNameONLY = UCase(Path.GetFileNameWithoutExtension(xls_fn))

        resp.Clear()
        resp.ClearContent()
        resp.ClearHeaders()
        resp.ContentType = "application/vnd.ms-excel"
        resp.AddHeader("Content-Disposition", "inline; filename=" & lcFileNameONLY & ".csv")
        For Each c In sqlTable.Columns
            resp.Write(UCase(c.ColumnName) & sep)
        Next
        resp.Write(vbCrLf)

        For Each r In sqlTable.Rows
            For i = 0 To sqlTable.Columns.Count - 1
                resp.Write(enq(r(i)) & sep)
            Next
            resp.Write(vbCrLf)
        Next

        resp.End()
        Return True

    End Function

End Class
  1. What’s causing this?
  2. How do I get around it?

I’m guessing it doesn’t really matter that the source of the data is a table.
Note that the file is created on the fly and never exists on the file system of the server.

tx,
tff

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T16:36:02+00:00Added an answer on May 20, 2026 at 4:36 pm

    Instead of using a Content-Disposition header that is Inline, use Attachment – this will always prompt for a download.

    Change the following line from:

    resp.AddHeader("Content-Disposition", "inline; filename=" & lcFileNameONLY & ".csv")
    

    To

    resp.AddHeader("Content-Disposition", "attachment; filename=" & lcFileNameONLY & ".csv")
    

    See this and this for examples.

    The inline type means that the browser is free to render it inline (within the browser), if in knows how to.

    And see this SO question, asking why inline sometimes prompts for downloads (the exact opposite of your question…).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm parsing an XML file, the creators of it stuck in a bunch social
I have a bunch of posts stored in text files formatted in yaml/textile (from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.