Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ReportViewer 500 - Internal server error.

Posted on 2009-07-15
4
Medium Priority
?
755 Views
Last Modified: 2012-06-27
Hello

I have setup a reportviewer on a asp.net webform.  It worked fine before I tried using IReportServerCredentials, it just prompted me for a username/password.  Now after implementing the credentials I keep getting a 500 error.  What am I doing wrong?
Imports System.Data
Imports System.Web
Imports System.Web.UI
Imports Microsoft.Reporting.Webforms
Imports System
Imports System.Net
Imports System.Configuration
Imports System.Collections
Imports System.Web.Security
Imports System.Security.Principal
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
 
 
Public Class GM
    Inherits System.Web.UI.Page
    Friend WithEvents SqlConnection As System.Data.SqlClient.SqlConnection
    Friend WithEvents SqlCommand As System.Data.SqlClient.SqlCommand
    Public strclientid As String = "https://www.mysite.com/ReportServer/Pages/ReportViewer.aspx?/" & HttpContext.Current.Request.Cookies("clientid").Value & "/"
 
    Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ReportViewer1.ServerReport.ReportServerUrl = New System.Uri("https://www.mysite.com/ReportServer/Pages/ReportViewer.aspx?/")
        ReportViewer1.ServerReport.ReportPath = HttpContext.Current.Request.Cookies("clientid").Value & "/execrecap&rs:Command=Render"
        ReportViewer1.ShowCredentialPrompts = False
        ReportViewer1.ServerReport.ReportServerCredentials = New MyReportServerCredentials()
 
        If Not Page.IsPostBack Then
            Dim Menu1 As Menu
            Menu1 = Me.Menu1
            Dim value As MenuItemBindingCollection
            value = Menu1.DataBindings
            Me.Page.DataBind()
            'menu setup here
            End If
    End Sub
End Class
Public NotInheritable Class MyReportServerCredentials
    Implements IReportServerCredentials
 
    Public ReadOnly Property ImpersonationUser() As WindowsIdentity _
            Implements IReportServerCredentials.ImpersonationUser
        Get
 
            'Use the default windows user.  Credentials will be
            'provided by the NetworkCredentials property.
            Return Nothing
 
        End Get
    End Property
 
    Public ReadOnly Property NetworkCredentials() As ICredentials _
            Implements IReportServerCredentials.NetworkCredentials
        Get
 
            'Read the user information from the web.config file.  
            'By reading the information on demand instead of storing 
            'it, the credentials will not be stored in session, 
            'reducing the vulnerable surface area to the web.config 
            'file, which can be secured with an ACL.
 
            'User name
            Dim userName As String = _
                ConfigurationManager.AppSettings("MyReportViewerUser")
 
            If (String.IsNullOrEmpty(userName)) Then
                Throw New Exception("Missing user name from web.config file")
            End If
 
            'Password
            Dim password As String = _
                ConfigurationManager.AppSettings("MyReportViewerPassword")
 
            If (String.IsNullOrEmpty(password)) Then
                Throw New Exception("Missing password from web.config file")
            End If
 
            'Domain
            Dim domain As String = _
                ConfigurationManager.AppSettings("MyReportViewerDomain")
 
            If (String.IsNullOrEmpty(domain)) Then
                Throw New Exception("Missing domain from web.config file")
            End If
 
            Return New NetworkCredential(userName, password, domain)
 
        End Get
    End Property
 
    Public Function GetFormsCredentials(ByRef authCookie As Cookie, _
                                   ByRef userName As String, _
                                   ByRef password As String, _
                                   ByRef authority As String) _
                                   As Boolean _
       Implements IReportServerCredentials.GetFormsCredentials
 
        authCookie = Nothing
        userName = Nothing
        password = Nothing
        authority = Nothing
 
        'Not using form credentials
        Return False
 
    End Function
End Class

Open in new window

0
Comment
Question by:jay-are
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24859262
Set the debug=true and disable the customerror pages in the web.config file to see where the problem is.
0
 

Author Comment

by:jay-are
ID: 24859310
Yeah debug is set to true and customErrors mode = off.  Not sure why I'm not seeing an actual error.
0
 
LVL 1

Accepted Solution

by:
dotnetchick earned 2000 total points
ID: 24874660
I believe in order for the report viewer control to function correctly, in the ReportServerUrl, you need to specify the path to the report server.  Then for ReportPath you need to give the directory structure and report name as the report it setup.
ReportViewer1.ServerReport.ReportServerUrl = New System.Uri("https://www.mysite.com/ReportServer/")
ReportViewer1.ServerReport.ReportPath = "Directory1/ReportName"

Open in new window

0
 

Author Comment

by:jay-are
ID: 24883438
I've got that exact setup now.  Ok so I had to go into the appsettings in IIS for that specific program and change it from version 3.5 back to "classic" or 2.0 to get the page to even load.  Now it loads fine but I don't get a reportviewer.  Just a blank iframe...
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question