473,396 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Download from a webpage

how to initiate a file download from an asp .net page?

thanks

Nov 21 '05 #1
6 1021
"Nikolay Petrov" <jo******@mail.bg> schrieb:
how to initiate a file download from an asp .net page?


'WebClient.DownloadFile'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2
if I use the WebClient, will it use the current configuration from the
browser, like proxy, cookies and other session specific information?

Nov 21 '05 #3
Nikolay,

You cannot set anything on the users computer using an aspnet page without
his acknowledge (and standard settings), normally it is for the donwload
(here it is an upload)

input type file
http://msdn.microsoft.com/library/de...e/elements.asp

I assume this does not help,

However better than nothing was my thought,

Cor
Nov 21 '05 #4
can I use Response.WriteFile

after testing an strange effect occured, instead initiating donwload,
the contents of the file are displayed in the browser window

Nov 21 '05 #5
Nikolay,

Can you do it with that acknowledge?
That is very normal by the way.

(The redirect what you see is the normal situation)
Cor
Nov 21 '05 #6
thanks for efforts, i've managed to find a way:

Dim filename As String = "C:\SomeFile.txt"
Dim FS As FileStream = New FileStream(filename, FileMode.Open)
Dim iFullSize As Integer = FS.Length
Response.Clear()
Response.AddHeader("Content-Type", "binary/octet-stream")
Response.AddHeader("Content-Disposition", _
"attachment; filename=DownloadedImage.txt; size=" _
+ iFullSize.ToString())
Response.AddHeader("Content-Length", iFullSize.ToString())
Response.Flush()
Dim chunkSize As Integer = 1024
Dim i As Integer
For i = 0 To iFullSize Step chunkSize
' Everytime check to see if the browser is still connected
If (Not Response.IsClientConnected) Then
Exit For
End If
Dim size As Integer = chunkSize
If (i + chunkSize >= iFullSize) Then
size = (iFullSize - i)
End If

Dim chunk(size - 1) As Byte
FS.Read(chunk, 0, size)
Response.BinaryWrite(chunk)
Response.Flush()
Next
FS.Close()

Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Alex | last post by:
Hi, Everyday, I download data from a webpage and manually input data into my MS Access database. I am thinking of automate the routine by a VB script. The webpage I am visiting will return a...
5
by: Alan Zhong | last post by:
i wonder how to download a webpage automatically using a C# program with WebClient class. i tried it and it's working. but somehow the data it gets is different than the page shown in microsoft...
18
by: jmd | last post by:
Hello, I posted the following in the C# forum but without one answer. But perhaps now in vb.net someone has some guidelines ! This is my question : I want to write a vb.net program that does...
0
by: ravibrl | last post by:
Hey I need c++ code to access a webpage and download some software. If I execute that it should download that software and it should install it in my system. Give suggestions how to write that code...
2
by: NOSPAM plz | last post by:
Hey, My problem is, is it possible to download parts of a file while. i think is it is called threading My code thats download the whole webpage, and stunds the app while is is downloading: ...
1
by: skinymike | last post by:
when i allow user to download a media file such as midi or wav files. It automatically open the files using Windows Media Player. Its fine works ok. But when i allow user to download a theme files...
1
by: I Haas | last post by:
C#, .Net framework 1.1 visual studio 2003 From a aspx page I want to open the dialog box (download;save/open/cancel) I want to close the aspx page after the dialogbox opens. I open the dialog...
1
by: smitanaik | last post by:
how to write an api to download contents from webpage
10
by: CJ | last post by:
Can someone tell me how to download a webpage complete with images and insert it into a richtextbox? Thanks
1
by: jambalapamba | last post by:
Hi all, I want to download images,css,js files referenced by a webpage. I am doing this by downloading the HTML of webpage and getting all the URL references in the html and using...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.