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

I have an asp.net 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 asp.net 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.Load(Server.MapPath("~/Reports/rptIncidentReport.rpt"))

        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
footpaulAsked:
Who is Participating?
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.

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

mlmcc
0
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.
0
mlmccCommented:
Where is this file

"~/Reports/rptIncidentReport.rpt"

mlmcc
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

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.
0
mlmccCommented:
Can you print or display the path it is trying to use

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

mlmcc
0
footpaulAuthor Commented:
C:\inetpub\wwwroot\IncidentReportingExternal\Reports\rptIncidentReport.rpt
which is the folder I granted full permissions to and still got the same result.
0
mlmccCommented:
Did you grant permissions to the report file itself?

mlmcc
0
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:

C:\Windows\SERVIC~2\NETWOR~1\AppData\Local\Temp

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.
0

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
mlmccCommented:
Glad you resolved this.

mlmcc
0
footpaulAuthor Commented:
While mlmcc was on the right track with permissions, I found the actual folder that needed the permissions on my own.
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.