Click here to Skip to main content
Rate this: bad
good
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) {
 
    Response.Redirect("Default2.aspx?filename=Csharp/CSharp.txt");              
}

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");
    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 24-Jul-12 21:42pm
Edited 24-Jul-12 21:46pm
v2
Rate this: bad
good
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 "transfer.page" I hope and has helped you a little anyway. Let us know if you found another solution Regards From Mexico.
  Permalink  
Comments
Prafulla Sahu at 28-Jul-12 5:49am
   
Thanks Rene for helped me,I solved like this way only
Rene Bustos at 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
good
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.
  Permalink  

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



Advertise | Privacy | Mobile
Web04 | 2.8.150301.1 | Last Updated 25 Jul 2012
Copyright © CodeProject, 1999-2015
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