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 45857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:52:30+00:00 2026-05-10T15:52:30+00:00

I have a page in my vb.net web application that needs to toss a

  • 0

I have a page in my vb.net web application that needs to toss a bunch of data into a text file and then present it to the user for download. What’s the best / most efficient way to build such a text file on a .net web server?

Edit: to answer a question down below, this is going to be a download once and then throw-away kind of file.

Update: I glued together the suggestions by John Rudy and DavidK, and it worked perfectly. Thanks, all!

  • 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. 2026-05-10T15:52:30+00:00Added an answer on May 10, 2026 at 3:52 pm

    The answer will depend on whether, as Forgotten Semicolon mentions, you need repeated downloads or once-and-done throwaways.

    Either way, the key will be to set the content-type of the output to ensure that a download window is displayed. The problem with straight text output is that the browser will attempt to display the data in its own window.

    The core way to set the content type would be something similar to the following, assuming that text is the output string and filename is the default name you want the file to be saved (locally) as.

    HttpResponse response = HttpContext.Current.Response; response.Clear(); response.ContentType = 'application/octet-stream'; response.Charset = ''; response.AddHeader('Content-Disposition', String.Format('attachment; filename=\'{0}\'', filename)); response.Flush(); response.Write(text); response.End(); 

    This will prompt a download for the user.

    Now it gets trickier if you need to literally save the file on your web server — but not terribly so. There you’d want to write out the text to your text file using the classes in System.IO. Ensure that the path you write to is writable by the Network Service, IUSR_MachineName and ASPNET Windows users. Otherwise, same deal — use content type and headers to ensure download.

    I’d recommend not literally saving the file unless you need to — and even then, the technique of doing so directly on the server may not be the right idea. (EG, what if you need access control for downloading said file? Now you’d have to do that outside your app root, which may or may not even be possible depending on your hosting environment.)

    So without knowing whether you’re in a one-off or file-must-really-save mode, and without knowing security implications (which you’ll probably need to work out yourself if you really need server-side saves), that’s about the best I can give you.

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

Sidebar

Ask A Question

Stats

  • Questions 61k
  • Answers 62k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Take a look at Code::Blocks May 11, 2026 at 9:56 am
  • added an answer To access a document library I would recommend going through… May 11, 2026 at 9:56 am
  • added an answer This is a bit of a pain on Windows. Here's… May 11, 2026 at 9:56 am

Related Questions

I have a page in my vb.net web application that needs to toss a
I have a page in my application that refreshes some content (a list of
I have a web page in which people go to register for my site.
I have a page that sites in a first level folder from my root
I have a log in page where I valid my users and based on
I have a import directive in my inline .aspx page (no code-behind). Getting an
I have forms in my page a get and a post and i want
I have a web page x.php (in a password protected area of my web
I have a menu of report links in my master page. I need to
I have an aspx page with a gridview. In my page load event, I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.