We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Response.Redirect is not working after saving PPTX

Hi Support,

When i export content to PPTX, respose.redirect is not working. below is my code snippets.

strHttpResCT = “application/vnd.ms-powerpoint”;
strHttpHdrCD = “attachment; filename=PowerPointFile.pptx”;
sfOutputFormat = Aspose.Slides.Export.SaveFormat.Pptx;

HttpContext.Current.Response.ContentType = strHttpResCT ;
HttpContext.Current.Response.AddHeader(“Content-Disposition”, strHttpHdrCD);
pptxFinal.Save(HttpContext.Current.Response.OutputStream, sfOutputFormat);

Please let me know me know if I miss anything over here.


Hi Rakesh,

Please share the sample presentation with us for further investigation on our end.

Many Thanks,

Below is the whole source code. we have to give end user option to save file own his location so we can’t use pres.write method to save PPTX file.

Code snippets:

PresentationEx pres = new PresentationEx();

//Accessing first slide
SlideEx slide = pres.Slides[0];
slide.Shapes.AddAutoShape(ShapeTypeEx.Rectangle, 0, 0, 500, 100);
slide.Shapes.AddAutoShape(ShapeTypeEx.Rectangle, 0, 305, 500, 100);

//Accessing the first and second placeholder in the slide and typecasting it as AutoShape
TextFrameEx tf1 = ((AutoShapeEx)slide.Shapes[0]).TextFrame;
TextFrameEx tf2 = ((AutoShapeEx)slide.Shapes[1]).TextFrame;

//Change the text in both placeholders
tf1.Text = “Margin by Aspose Margin by Aspose Margin by Aspose Margin by Aspose”;
tf2.Text = “Indent by Aspose Indent by Aspose Indent by Aspose Indent by Aspose”;

//Getting the first paragraph of the placeholders
ParagraphEx para1 = tf1.Paragraphs[0];
ParagraphEx para2 = tf2.Paragraphs[0];
para2.BulletType = BulletTypeEx.Numbered;
ParagraphEx para3 = new ParagraphEx();
para3.BulletType = BulletTypeEx.Numbered;
para3.Indent = 144;
para3.Alignment = TextAlignmentEx.Center;
para3.Text = “Indent by Aspose Indent by Aspose Indent by Aspose Indent by Aspose”;
para1.MarginLeft = 72;
para2.Indent = 144;
// para3.MarginLeft = 72;

float Par1Margin = para1.MarginLeft;

string strHttpResCT = “application/vnd.ms-powerpoint”;
string strHttpHdrCD = “attachment; filename=PowerPointFile.pptx”;
Aspose.Slides.Export.SaveFormat sfOutputFormat = Aspose.Slides.Export.SaveFormat.Pptx;

HttpContext.Current.Response.ContentType = strHttpResCT;
HttpContext.Current.Response.AddHeader(“Content-Disposition”, strHttpHdrCD);
pres.Save(HttpContext.Current.Response.OutputStream, sfOutputFormat);

Hi Rakesh,

I have worked with the code shared by you. Actually, you are using two responses at one time. Only one of them can be entertained at one time. This issue is not related to Aspose.Slides. If you export any file in stream from browsers and user will set the page to modal for file path selection. The redirect may not work. You may need to devise some approach to cater your requirement of exporting presentation over stream and letting user to select path and at the same time redirecting your page to some other page. I have used Response.End() and there was no issue. Please observe following web links for your kind reference.
Many Thanks,