TEALTEAL
asked on
Export Crystal Reports To PDF from ASP.NET
I am getting the error:
Access to the path "C:\WINDOWS\TEMP\export_bb 06d6ee-4b1 a-49ad-972 8-bdf29218 1a0a.tmp" is denied.
when trying to export to a pdf.. From another app on the server this is working, so I'm a bit stumped at what the problem is.. Any ideas???
Thanks in advance!!!
Access to the path "C:\WINDOWS\TEMP\export_bb
when trying to export to a pdf.. From another app on the server this is working, so I'm a bit stumped at what the problem is.. Any ideas???
Thanks in advance!!!
This is the code that I use to export a Crystal Report to a PDF file (opens in a browser window) without writing anything to disk:
reportObject.SetDataSource (dataSet);
System.IO.Stream st;
st = reportObject.ExportToStrea m(ExportFo rmatType.P ortableDoc Format);
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/PDF";
byte[] b = new byte[st.Length];
st.Read(b,0,(int) st.Length);
Response.BinaryWrite(b);
Response.Flush();
Response.Close();
reportObject.SetDataSource
System.IO.Stream st;
st = reportObject.ExportToStrea
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/PDF";
byte[] b = new byte[st.Length];
st.Read(b,0,(int) st.Length);
Response.BinaryWrite(b);
Response.Flush();
Response.Close();
srafi78 is right, you need to set the permissions on the temp folder.
I had to grant Full permission for user Everyone on both my report and temp folders in order to not get that error - perhaps a bit overkill but it works for me. BTW, I put my pdf temp folder in the same virtual directory as my application - not Windows.
Jan
I had to grant Full permission for user Everyone on both my report and temp folders in order to not get that error - perhaps a bit overkill but it works for me. BTW, I put my pdf temp folder in the same virtual directory as my application - not Windows.
Jan
As I recall the TEMP directory gets used regardless of where the file actually goes. Crystal creates several temporary files when it creates a report.
mlmcc
mlmcc
ASKER
I'll have to check a couple more setting on Monday.. On my local machine everything works fine.. I have one application on the server that works fine, but another app (different virtual diretory) I get the error regarding the permissions to the temp file.. Do you know what setting could be missing from the app? I am the same user, so I'm a little unclear what the issue is..
Hi TEALTEAL...
This sollution applies to .NET
I had this exact problem over the weekend. No matter what I did to IIS settings or User settings, nothing helped...
Eventually I set my project's (right click in the sollution browserr) properties->web settings->web access mode to "Frontpage extentions".
This allows one to set (with the project selected in the sollutions browser) Project->Web Project->Web permisions to "Use unique permissions" which then allows you to set the user permissions to "Author and browse" (on the same page).
And only then could my asp.net app export .pdf files.
This sollution applies to .NET
I had this exact problem over the weekend. No matter what I did to IIS settings or User settings, nothing helped...
Eventually I set my project's (right click in the sollution browserr) properties->web settings->web access mode to "Frontpage extentions".
This allows one to set (with the project selected in the sollutions browser) Project->Web Project->Web permisions to "Use unique permissions" which then allows you to set the user permissions to "Author and browse" (on the same page).
And only then could my asp.net app export .pdf files.
Sorry, that was Group: DOMAIN\user permissions right at the end...
Cheers
Z
Cheers
Z
ASKER
My properties->web settings->web access mode to "Frontpage extentions".
is grayed out.. So I"m unable to change.. Any idea how to fix that?
Thanks again...
is grayed out.. So I"m unable to change.. Any idea how to fix that?
Thanks again...
Make sure you're not in debug mode... Press Shit-F5 to be in editing mode.
Hope it is just that...
Cheers
Z
Hope it is just that...
Cheers
Z
ASKER
Still grayed.. out .. any other ideas?
Did you try setting full permission for user EVERYONE on your temp folder? Can you create a new temp folder in your virtual directory so you don't need to write to an OS directory?
for related issue see: https://www.experts-exchange.com/questions/21544812/Crystal-report-Not-showing-any-data.html#14787186
for related issue see: https://www.experts-exchange.com/questions/21544812/Crystal-report-Not-showing-any-data.html#14787186
ASKER
Actually with user EVERYONE on the temp folder.. It does work.. However the network admin's will not permit this for production. Do you know how I can have crystal write to a different temp directory instead of teh OS temp directory??
Thanks again
Thanks again
You can change the Temp Directory Location like.......
Control Panel >> Internet Options >> On General tab Select Settings >> Move Folder and then specify your own location.
Note this will be just for your User account. To change the location on the server you have to login as an admin to do the job.
While using ASP and Crystal I had the same prob, for me when I set the IIS User permissions on the destination folder I was able to export the Crytal Report to the destinal folder in PDF/Excel format.
HTH.
Control Panel >> Internet Options >> On General tab Select Settings >> Move Folder and then specify your own location.
Note this will be just for your User account. To change the location on the server you have to login as an admin to do the job.
While using ASP and Crystal I had the same prob, for me when I set the IIS User permissions on the destination folder I was able to export the Crytal Report to the destinal folder in PDF/Excel format.
HTH.
Create a folder named "Temp" in the same folder that contains your .net application. Assign Full rights to user Everyone on that folder. In your application when you export to pdf use Server.MapPath("") & "\temp\" & filename (I can send you the exact code this evening when I get home)
ASKER
janmarini--
If you could post the exact code that would be great.. Thx!
If you could post the exact code that would be great.. Thx!
Here's the code I am using - see <==== below for comments on the folders used
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim crReportDocument As New CrystalDecisions.CrystalRe
Dim ReportName As String = DirectCast(Session("gblrep
ReportName = "/Report Files/" & ReportName
crReportDocument.Load(Serv
Call LogonReport(crReportDocume
If Session("glbReportSelectio
crReportDocument.RecordSel
Session("glbReportSelectio
End If
'-------------------
'To view the report in the CR Viewer
'crv1.ReportSource = crReportDocument
'-------------------
'-------------------
'To Export to PDF - Note: If access to report file denied error need to grant full permissions
'on Temp Folder, and full permissions to VS Developer on wwwroot '<====Try this
'-------------------
Dim exportOpts As New ExportOptions()
exportOpts = crReportDocument.ExportOpt
exportOpts.ExportDestinati
exportOpts.ExportFormatTyp
'temp pdf file name - uses SessionID+JulianDateTime
'-------------------------
Dim diskOpts As New DiskFileDestinationOptions
Dim strServerPath As String
Dim strFile As String
Dim strPDFFile As String
Dim convertDate As New System.Globalization.Grego
Dim julianValue As String
Dim julianYear As String = convertDate.GetYear(Now)
Dim julianDay As String = convertDate.GetDayOfYear(N
Dim julianTime As String = convertDate.GetSecond(Now)
julianValue = julianYear + julianDay + julianTime
strServerPath = Server.MapPath("") & "\temp" '<==== The Temp folder you created in your virtual directory
strFile = Session.SessionID & julianValue & ".pdf"
strPDFFile = strServerPath & "\" & strFile
diskOpts.DiskFileName = strPDFFile
exportOpts.DestinationOpti
crReportDocument.Export()
crReportDocument.Close()
crReportDocument.Dispose()
'Display pdf document in frame2 of the Frameset
'-------------------------
Response.Write("Report Start: " & Reportstart & " Report End: " & Reportfinish & " Pdf Start: " & PdfStart & " Pdf End: " & PdfFinish)
Dim ScriptStr As String = "<Script language='javascript'>wind
Response.Write(ScriptStr)
End Sub
ASKER
Thanks for posting.. It looks like this is still writing temp file to the c:windows/temp folder before it gets saved into
Server.MapPath("") & "\temp
What privledges does your C:Windows\Temp file have?
Server.MapPath("") & "\temp
What privledges does your C:Windows\Temp file have?
Users: Administrators, System and Users have full permissions
ASKER
I'm still working on .. I believe that my problem lies in teh the facts that you need to give permission the to c:\windows\temp folder... I was hoping I could change something in crystal to write the temp files to another location, but it doesn't look like you can????
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Bascially I had to add a subfolder for my reports and add a web.config file in order to impersonate a specific user..........Thanks.
HTH