Using SSRS with ASP.Net ReportViewer
I have set up SSRS on my localhost, and used BIDS to create a couple of reports on them. They access data from the same SQL Server where the SSRS is depl开发者_C百科oyed, and when I preview them they run fine. Then I deployed them to my localhost SSRS and accessed them via the ReportManager web interface, again they ran just fine. Finally I deployed them to my hosting provider's SSRS. Same deal; good data connectivity and it looks great in the ReportManager.
The first time I access them through the ReportManager on either system, it demands my username and password, which on my laptop is just my account logon and password. For my hosting provider it's my account logon for them.
My problem is when I try to display a report using the ReportViewer control in ASP.Net. Very often, when it tries to render I get a "Bad Logon" or "401: Unauthorized" instead of my report. After a lot of reading and pondering, I believe the problem is that I need to log on not to the SQL Server, but to the website (web service?) where my reports are exposed. Right now if I don't provide any credentials at all, I can get my local reports in the ReportViewer (usually). However, when I deploy the reports to a remote server, this doesn't work anymore.
After some research I created a class that implements IReportServerCredentials and tried using it to pass in the username and password, but this doesn't appear to work. And it was confusing me whether these credentials are supposed to be for the data source or for the web service.
If anyone could clue me in on how to get the ReportViewer to log in to the SSRS web service, I'd much appreciate it.
Assuming that you have set the ProcessingMode="Remote" attirbute on the viewer, then you probably have an authentication issue. When using the report viewer in remote mode, the report is executed on SSRS by the account ASP.Net is running under. This account must have access to the reporting server and to the report you want to run. What is probably happening is that ASP.Net is running under an account that does not have access to SSRS.
If you want to be able to set the credentials for the report viewer, take a look at this thread for a solution and sample code.
It's always challenging to debug authentication issues remotely, but you might able to solve your problem by enabling impersonation on your AppPool. That way, when a user is logged-in, IIS would be able to connect to SQL Server as your user.
Another approach might be to use SQL Authentication; unfortunately, the details depend on how you have things hooked up.
精彩评论