Access is denied. error recieved when trying to view crystal report.

I have an webpage that has been created using Visual Studio 2010. I use Crystal Reports for Visual Studio 2010 and have 1 report in my application. The report loads and works fine when the website is run from my local machine using Visual Studio. When run from the server the webpage is published on, I recieve an "Access is denied." error. In my web.config file, I do have impersonate set to true and if I use my username and password (network administrator) for the values in the web.config file, the report loads and looks fine with no error. If I use the username and password we have created for this application, I get the error. I have granted full permission for this user to the windows temp folder on the c drive of the server and also to the temp folder on the server. This problem obviously is related to permissions, what folder am I forgetting?

Here is the error message:

Access is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Access is denied.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace:

[COMException (0x80004005): Access is denied.
   CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options) +0
   CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options) +147
   CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +422

[CrystalReportsException: Load report failed.]
   CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +549
   CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob) +1613
   CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename) +189
   Pages_IncidentReportViewer.Page_Init(Object sender, EventArgs e) +132
   System.Web.UI.Page.OnInit(EventArgs e) +105
   System.Web.UI.Control.InitRecursive(Control namingContainer) +133
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1954


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

In case it is of use, here is the code used to load the report:


        report.SetParameterValue(0, CInt(Session("ReportOnlineIncidentID")))
        report.SetParameterValue(1, CInt(Session("ReportOnlineIncidentID")))
        report.SetParameterValue(2, CInt(Session("ReportOnlineIncidentID")))
        report.SetDatabaseLogon("*****", "********")

        crvTest.ReportSource = report
        crvTest.DisplayGroupTree = False
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Did you give permissions to the RPT file itself and its folder?

footpaulAuthor Commented:
I don't specifiy where the temp report file is saved so I assume it goes wherever is the default location. I don't know where that is either.
Where is this file


IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

footpaulAuthor Commented:
On the server, the application lives in the inetpub folder, under wwwroot, then the application folder, then the reports folder is there. I did just now grant full permissions to the reports folder to no avail.
Can you print or display the path it is trying to use

msgbox Server.MapPath("~/Reports/rptIncidentReport.rpt")

footpaulAuthor Commented:
which is the folder I granted full permissions to and still got the same result.
Did you grant permissions to the report file itself?

footpaulAuthor Commented:
I only granted permissions to the entire folder but I did check the report file itself and this did give the account full permissions to it as well. This still didn't solve my issue. I did however find a way to see where the website was storing temporary files by using this line of code:

Label1.Text = System.Environment.GetEnvironmentVariable("TMP").ToString

This showed me that the temp folder the website was using was:


The NETWORK SERVICE account by default has access to this folder but since I was impersonating per my web.config file, I needed to grant permissions to my website user account. This solved my issue. Thanks for your help though.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Glad you resolved this.

footpaulAuthor Commented:
While mlmcc was on the right track with permissions, I found the actual folder that needed the permissions on my own.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.