Click here to Skip to main content
15,888,263 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi
I have a problem with Download module. My requirement is that, after downloading a document or a file, i need to redirect to another page. Is it possible? I already tried like

1. Response.Redirect("~/xyz.aspx");

2. Server.Transfer

3. Response.Write("<script type="text/javaScript"> window.location.href = '~/xyz.aspx'; </script>");

Here i am putting my Code:
C#
string URL = Server.MapPath("~/xyz.pdf");
        FileInfo fileInfo = new FileInfo(URL);

        if (fileInfo.Exists)
        {
            Response.Clear();
            Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileInfo.Name);
            Response.AppendHeader("Content-Length", fileInfo.Length.ToString());
            Response.ContentType = "application/pdf";
            Response.Flush();
            Response.WriteFile(fileInfo.FullName);

            Response.Write("<script type="text/javaScript"> window.location.href = 'Default.aspx'; </script>");
        }
        else
        {
                    Response.Write("<script>alert('Sorry u cant download file!')</script>");
        }

They dont work. Please help me its urgent.
Waiting for the response & Please let me know where i made a mistake.
its urgent.

thank u
Posted
Updated 31-May-10 21:32pm
v2

Here's a nice example of how it could be done:

http://encosia.com/2007/02/23/ajax-file-downloads-and-iframes/[^]
 
Share this answer
 
Once you write your header content you can't change it to something else. I'm not sure if what you want to do will work. You need to work around it.

One way to work around them is, open your download link in new window and then you can redirect to different window from the parent window.
 
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