×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

disable open/save prompt while saving pdf to server

disable open/save prompt while saving pdf to server

disable open/save prompt while saving pdf to server

(OP)
Hello,

I have reporting services report viewer.  I am loading a server report to the viewer.  This works fine.  I have a button and when it is clicked, I want to export the report to PDF and save it on the server.

When the user clicks the button, the pdf is being saved just fine on the server, but I'm getting an open/save prompt anyway..even though the pdf has already been saved on the server.  How can I disable that prompt?

Here is the code.

CODE

Dim warnings As Microsoft.Reporting.WebForms.Warning() = Nothing
            Dim streamids As String() = Nothing
            Dim mimeType As String = Nothing
            Dim encoding As String = Nothing
            Dim extension As String = Nothing
            Dim DeviceInfo As String = "<DeviceInfo>" _
                & "  <OutputFormat>PDF</OutputFormat>" _
                & "  <PageWidth>8.5in</PageWidth>" _
                & "  <PageHeight>11.5in</PageHeight>" _
                & "  <MarginTop>0.5in</MarginTop>" _
                & "  <MarginLeft>0.5in</MarginLeft>" _
                & "  <MarginRight>0.4in</MarginRight>" _
                & "  <MarginBottom>0.4in</MarginBottom>" _
                & "</DeviceInfo>"
            Dim bytes As Byte()
            bytes = rpv1.ServerReport.Render("PDF", DeviceInfo, mimeType, encoding, extension, streamids, warnings)

            Response.Clear()
            Response.ContentType = mimeType
            Response.AddHeader("content-disposition", "attachment; filename=Test7." & extension)
            Try

                File.WriteAllBytes("C:\onetwothree.pdf", bytes)
    
            Catch ex As Exception
                
            End Try

            Response.End()

 What am I doing wrong?  Any ideas?

________________________________________________
"I have not failed. I've just found 10,000 ways that won't work."-Thomas Edison

 

RE: disable open/save prompt while saving pdf to server

the default behavior is to prompt the user to open/save/cancel on the client. You saved the file on the server, not the client. To by pass this and open the PDF directly in the browser change the content hearder to

CODE

Response.AddHeader("content-disposition", "inline; filename=Test7." & extension)
also remove the try/catch. you are just swallowing the exception which is the worst thing you can do. you will have no idea why it fails if/when it does fail.

Jason Meckley
Programmer
Specialty Bakers, Inc.

FAQ855-7190: Database Connection Management

RE: disable open/save prompt while saving pdf to server

(OP)
Thanks for the help.  Is there a way to just save it and not display it in any way?  

Also, I had some error handling code in the try/catch block but removed it before posting for brevity.

________________________________________________
"I have not failed. I've just found 10,000 ways that won't work."-Thomas Edison

 

RE: disable open/save prompt while saving pdf to server

once the file is saved (on the server) redirect the user to another page.

CODE

SaveFile();
Response.Redirect("anotherpage.aspx?querystring=value", false);
if you want to save the file on the client you either need to prompt the user to save/open/cancel, or display the report in the browser and have the user save the file.
You cannot have the server automatically save the file to an arbitrary location on the client's machine.

Jason Meckley
Programmer
Specialty Bakers, Inc.

FAQ855-7190: Database Connection Management

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close