How to access Reporting Services from Web App

Discussion in 'ASP.NET WebServices' started by reporter, Feb 10, 2007.

  1. Hi All,

    I have report sever on my local workstation and it works fine. However,I am having difficulty understanding how to acces the discountasp reporting server from a asp.net 2.0 web application.
    Where do we store our logon credentials - web config? Are we allowed to createa Browser Role within our allocated server space as I diod on my local report server?
    Are there any How-Tos specific to this environment? Any help would be appreciated.

    Thanks,
    RK
     
  2. Here's sample code on how to render reports from a web application. Note that this if for MS SQL 2000 Reporting Server.

    http://kb.discountasp.net/article.aspx?id=10335

    DiscountASP gives you one report user. So your web application will have to determine whichlogged onuser gets to see what reports.


    Aristotle

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. Bruce

    Bruce DiscountASP.NET Staff

  4. Thanks Aristotle. I actually saw that article and it is indeeed helpful. I was looking to see if there was anything else available
    that contained more specific information.This article appears to leave out"the proxy class to point to the web service" and I
    am trying to eliminate as much guesswork as reasonably possible.

    Thanks,
    RK
     
  5. Thanks Bruce.

    I am actually trying to use the report viewer, however I cannot get past a persistent 401 authentication error.



    <LI style="DISPLAY: inline; FONT-WEIGHT: normal; FONT-SIZE: 8pt; FONT-FAMILY: Verdana">
    <LI style="DISPLAY: inline; FONT-WEIGHT: normal; FONT-SIZE: 8pt; FONT-FAMILY: Verdana">The request failed with HTTP status 401: Unauthorized.

    It appears that when I try access the report server from the report viewer I receive this authentication error. Apparently I am not even
    getting past the report server authentication process. Hence my question on how do we access the report server from the web app.
    I am wondering - where do we tell the report server that I am xxx and my password is yyy and I am allowed to view report zzzz when
    I am usinga report viewer as opposed to rendering a report as in the example provided by Aristotle?


    Thanks,
    RK
     
  6. Bruce

    Bruce DiscountASP.NET Staff

  7. Thanks Bruce! I went with he report viewer and local report option. Turns out that report server was overkill for my needs
    and local report worked just fine.. Thanks for the advice, much appreciated.


    RK
     
  8. I am experiencing the same "The request failed with HTTP status 401: Unauthorized." error using the discountasp.net SSRS and the report viewer control. I do not want to use a local report as I purchased SSRS from Discountasp.net so that I could use its additional capabilities above and beyond what local reports offers.

    I need help with authentication...

    When creating the ServerReport.ReportServerCredentials do I need to create a Nework credential, Windows identity or some form of Forms identity?
    Can you post some code to demonstrate how to connect and authorize a reportviewer control against your specific implementation of SSRS?

    There are numerous solutions on the web but none that I have found, after several hours of testing, appear to work.

    Thanks
     
  9. After a lot of frustrating hours being presented with HTTP 404 errors and the Unauthorized error I finally figured it out. The code is below. Hope it helps someone:


    using System;


    using System.Collections;


    using System.Configuration;


    using System.Data;


    using System.Linq;


    using System.Net;


    using System.Web;


    using System.Web.Security;


    using System.Web.UI;


    using System.Web.UI.HtmlControls;


    using System.Web.UI.WebControls;


    using System.Web.UI.WebControls.WebParts;


    using System.Xml.Linq;


    using Microsoft.Reporting.WebForms;


    using System.Security.Principal;


    public partial class Default : System.Web.UI.Page


    {


    protected void Page_Load(object sender, EventArgs e)


    {


    ReportViewer1.ServerReport.ReportServerUrl = new Uri("https://<YourDiscountASP.NetSSRS e.g. rs2k501.discountasp.net>/reportserver");


    ReportViewer1.ServerReport.ReportPath = "<PathToReport>";


    IReportServerCredentials irsc = new CustomReportCredentials("<UserName>", "<Password>", "<YourDiscountASP.NetSSRS e.g. rs2k501.discountasp.net");


    ReportViewer1.ServerReport.ReportServerCredentials = irsc;








    }


    public class CustomReportCredentials : Microsoft.Reporting.WebForms.IReportServerCredentials


    {


    // local variable for network credential


    private string _UserName;


    private string _PassWord;


    private string _DomainName;


    public CustomReportCredentials(string UserName, string PassWord, string DomainName)


    {


    _UserName = UserName;


    _PassWord = PassWord;


    _DomainName = DomainName;


    }


    public WindowsIdentity ImpersonationUser


    {


    get


    {


    return null; // not use ImpersonationUser


    }


    }


    public ICredentials NetworkCredentials


    {


    get


    {


    return new NetworkCredential(_UserName, _PassWord, _DomainName);


    }


    }


    public bool GetFormsCredentials(out Cookie authCookie, out string user, out string password, out string authority)


    {


    // not use FormsCredentials unless you have implements a custom autentication.


    authCookie = null;


    user = password = authority = null;


    return false;


    }


    }





    }
     
  10. Bruce

    Bruce DiscountASP.NET Staff

  11. Thanks so much, that really worked, i have been trying to find a solution for a complete day. thanks thanks.. a lot for your solution.
     

Share This Page