Click here to Skip to main content
13,140,591 members (44,878 online)
Rate this:
Please Sign up or sign in to vote.
I have a page which has a LinkButton,my requirement is when i click on 'DownLoad; Linkbutton the page should redirect to another page and there my file should be download and my web page address bar should display that which page it is redirecting also my querystring value. please suggest me how would I do that please help me.

here is my code

FirstPage.aspx :
protected void LinkButton1_Click(object sender, EventArgs e) {

Download.aspx :
protected void Page_Load(object sender, EventArgs e) 
    string filename = Request.QueryString["filename"];
    Response.ContentType = "text";
    Response.AppendHeader("Content-Disposition", "attachment; filename=CSharp.txt");

I used this code in each and every event of Download.aspx page event but i couldn't.
note:I have this requirement exactly that i have to use querystring and also the redirected page and querystring value should show in the address bar before download.
Posted 24-Jul-12 20:42pm
Updated 24-Jul-12 20:46pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You've tried to setTimeOut within the download.aspx? I mean, when do the redirect to the page Download.aspx in on_load method (codebehind) or javascript (client) of this download page, a few seconds and call again to send the page with a parameter that makes it download the file that way you can see the download page in the browser remember that if a page contains a download start, this behaves as a "" I hope and has helped you a little anyway. Let us know if you found another solution Regards From Mexico.
Prafulla Sahu 28-Jul-12 5:49am
Thanks Rene for helped me,I solved like this way only
Rene Bustos 31-Jul-12 1:05am
Perfect Prafulla..
See you later and good job
regards from mexico
Can you ckeck this solution? :) regards!!
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

What you can do is to have a page where it redirects normally and you can use client side code to point to the file. In that way the browser will show the URL and the download will also be possible.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170915.1 | Last Updated 25 Jul 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100