Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 30, 2012 07:31 AM by Mudasir.Khan
Member
26 Points
62 Posts
May 30, 2012 07:10 AM|LINK
Hi
For download a file I use below code:
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
String FilePath = @"~\myfolder\myfile.pdf";
HttpContext context = HttpContext.Current;
context.Response.AppendHeader("content-disposition", "attachment; filename= myfile.pdf");
context.Response.ContentType = "application/ZipFile";
context.Response.TransmitFile(FilePath);
}
else
But after do it , below code (a button for Redirect to another page) don’t operate. Why?
try
Response.Redirect("~/myfolder/mypage2.aspx?returnUrl= mypage1.aspx");
catch
Thanks very much
All-Star
15346 Points
3142 Posts
May 30, 2012 07:31 AM|LINK
for a request you can have only one response so then download file is appended in header the response is to download the file it can do anything to the page, so first redirect then start the download page using ajax or iframe
armm1388
Member
26 Points
62 Posts
my button Don’t Redirect after use of method " TransmitFile" ) (VS2010 – C#)
May 30, 2012 07:10 AM|LINK
Hi
For download a file I use below code:
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
String FilePath = @"~\myfolder\myfile.pdf";
HttpContext context = HttpContext.Current;
context.Response.AppendHeader("content-disposition", "attachment; filename= myfile.pdf");
context.Response.ContentType = "application/ZipFile";
context.Response.TransmitFile(FilePath);
}
else
{
}
But after do it , below code (a button for Redirect to another page) don’t operate. Why?
try
{
Response.Redirect("~/myfolder/mypage2.aspx?returnUrl= mypage1.aspx");
}
catch
{
}
Thanks very much
Mudasir.Khan
All-Star
15346 Points
3142 Posts
Re: my button Don’t Redirect after use of method " TransmitFile" ) (VS2010 – C#)
May 30, 2012 07:31 AM|LINK
for a request you can have only one response so then download file is appended in header the response is to download the file it can do anything to the page, so first redirect then start the download page using ajax or iframe