Reporting Services Error: System.Net.WebException: The request failed with HTTP status 401: Unauthorized.

I am migrating a visual studio 2008 web application to visual studio 2010.
This web application is using a report viewer control.
I have removed the 2008 reportviewer control and added the 2010 reportviewer control.

When i attempt to load the report inside the web page i get the following error:

[WebException: The request failed with HTTP status 401: Unauthorized.]
   Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.GetSecureMethods() +204
   Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.IsSecureMethod(String methodname) +47
   Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.SetConnectionSSLForMethod(String methodname) +12
   Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.ProxyMethodInvocation.Execute(RSExecutionConnection connection, ProxyMethod`1 initialMethod, ProxyMethod`1 retryMethod) +446
   Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.LoadReport(String Report, String HistoryID) +178
   Microsoft.Reporting.WebForms.ServerReport.EnsureExecutionSession() +79
   Microsoft.Reporting.WebForms.ServerReport.SetParameters(IEnumerable`1 parameters) +69
   extranet.printpog1.Page_Load(Object sender, EventArgs e) +401
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

Open in new window


Here is the code from my web application:

            <rsweb:ReportViewer
            CssClass="reportviewercss"
            ID="ReportViewer1" 
            runat="server" 
            Font-Names="Verdana" 
            PromptAreaCollapsed="true"   
            ShowPromptAreaButton="false"            
            Height="800px" 
            ProcessingMode="Remote"
            ExportContentDisposition="AlwaysInline" 
            Width="1025px">
                <ServerReport 
                ReportPath="/Sales/Online Ordering/Product Order Guide"  
                ReportServerUrl="http://server.domain.com/ReportServer"
                />
            </rsweb:ReportViewer>

Open in new window


I am using the same application pool identity as i did in the vs 2008 version of this web application, so i am not sure what the trouble is.

Maybe there is some trickery needed so that a vs 2010 application can communicate with a 2005 report server?

Any thoughts?
Jason
jsvb1977Asked:
Who is Participating?

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

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

lcohanDatabase AnalystCommented:
What about authentication/rights to the report folder in new page? is it the same user and are the SSRS rights granted to that NT user to run the report?
jsvb1977Author Commented:
Icohan,

Thanks for the reply. I am having trouble understanding what you mean.
Its likely my fault that I do not understand, though.

Would you mind attempting to clarify your question a little bit more for me?

Jason
lcohanDatabase AnalystCommented:
Sure, the new page you are trying to access will be executed under current NT login and does that login have sufficient rights for SSRS report to run in that page? Here's how Authentication works in Reporting Services:

http://technet.microsoft.com/en-us/library/ms152899.aspx

Active Protection takes the fight to cryptojacking

While there were several headline-grabbing ransomware attacks during in 2017, another big threat started appearing at the same time that didn’t get the same coverage – illicit cryptomining.

jsvb1977Author Commented:
ok, well i made an assumption that the application pool identity that is assigned to this web application is the user that will be authenticating against the report server.

If i am correct, then the answer to your question would be "yes, this user has rights to run the report."

The thing that makes me concerned is that this exact same code is running properly in the following locations:

1. IIS 7.5 on the Production Server [Web Server 2008]
2. In VS 2008 Debug on an XP Machine [IIS 6.0]

Both of the above environments use the same Applicatin Pool Identity to access the report that I am trying to embed in my VS 2010 asp.net web page.

Jason
lcohanDatabase AnalystCommented:
And more speciffic hopefully similar answer to what you are looking for:

http://stackoverflow.com/questions/2067976/using-ssrs-with-asp-net-reportviewer


Also at this link below you can see hou to use a "dummy" non Windows AD user:

http://forums.asp.net/t/1638562.aspx/1
lcohanDatabase AnalystCommented:
<<The thing that makes me concerned is that this exact same code is running properly in the following locations:

1. IIS 7.5 on the Production Server [Web Server 2008]
2. In VS 2008 Debug on an XP Machine [IIS 6.0]
.>>


Are you using the same NT login on both when you run the report? than that's your answer as the authentication between service(web site app pool) and sql db is usualy done on the backend on the same user. If you want each user to have their own page/report rights please see more below:

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

http://stackoverflow.com/questions/2067976/using-ssrs-with-asp-net-reportviewer

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
jsvb1977Author Commented:
No, I do not want each user that access the website to have their own page/report rights. I want to control the rights 'globally' -- which is what i thought i was doing with the application pool identity.

I am looking into something like this:

ReportViewer1.ServerReport.ReportServerCredentials = new ReportServerCredentials("username", "pwd", "domain");

As per one of the links you provided.
I will keep you posted...

Jason
jsvb1977Author Commented:
So, here is what i had to do to get this report to run in my asp.net vs 2010 application:

1. I had to define the user that will access the report in the code behind [as per my post above].
2. I had to upgrade my application to .Net 3.5 and include the Script Manager from the Toolbox
3. I had to move my report to SQL Server 2008 Reporting Services [embedding ssrs 2005 reports into vs 2010 is not possible] (Confirmation on this?)
4. I had to wrap the initial PageLoad Report Routines in the code behind in a IsPostBack

Thank you for the resources to help me get this done.
Jason
jsvb1977Author Commented:
Here is the direct link to the page that i used to build the class that i call to authenticate against the report server:

http://social.msdn.microsoft.com/forums/en-US/vsreportcontrols/thread/c65abca7-0fdb-40fb-aabe-718f63377a55/

ASP.Net SSRS Authentication Class

Jason
lcohanDatabase AnalystCommented:
Honestly I never tried that as we migrated(upgraded) all the reports from 2005 to 2008 before using them in VS2008 and/or 2010.
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
ASP.NET

From novice to tech pro — start learning today.