Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 :
C#
protected void LinkButton1_Click(object sender, EventArgs e) {

    Response.Redirect("Default2.aspx?filename=Csharp/CSharp.txt");              
}

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

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
Updated 24-Jul-12 20:46pm
v2

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 "transfer.page" I hope and has helped you a little anyway. Let us know if you found another solution Regards From Mexico.
 
Share this answer
 
Comments
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!!
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900