ASP .net SQL Server Reporting Services 401 Error

Discussion in 'ASP .Net' started by RSH, Jun 29, 2007.

  1. RSH

    RSH Guest

    Hi,

    I am trying to access a reporting services report using the HTTPWebRequest
    object but I am getting an error:
    The remote server returned an error: (401) Unauthorized.
    We can't seem to figure this out...the link works fine if I enter it
    directly in a browser, just not when I try to hit through the HTTPWebRequest
    object.

    Thanks for any possible solutions!
    Ron


    Private Sub ReportSaveTest()

    Dim strLink As String =
    "http://svr/ReportServer$svr?/WebServiceTest&rs:Command=Render&rs:format=HTML4.0"

    Dim myCred As New Net.NetworkCredential

    myCred = New System.Net.NetworkCredential("user", "pass", "dimain")

    Dim ox As System.Net.HttpWebRequest

    ox = System.Net.HttpWebRequest.Create(strLink)

    ox.PreAuthenticate = True

    ox.Credentials = myCred

    Dim oy As System.Net.HttpWebResponse = ox.GetResponse() <<<<<<<<<<<<<<
    ERRORS OUT HERE

    Dim raw As System.IO.FileStream = New
    System.IO.FileStream(Request.PhysicalApplicationPath & "TesFile.pdf",
    IO.FileMode.Create)



    Dim buffer(1024) As Byte

    Dim rs As System.IO.Stream = oy.GetResponseStream()

    Dim read As Integer = rs.Read(Buffer, 0, Buffer.Length)

    While (read > 0)

    raw.Write(buffer, 0, read)

    read = rs.Read(buffer, 0, buffer.Length)

    End While

    oy.Close()

    raw.Close()

    rs.Close()

    oy = Nothing

    ox = Nothing

    raw = Nothing

    rs = Nothing

    End Sub
    RSH, Jun 29, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark
    Replies:
    1
    Views:
    438
    Natty Gur
    Nov 25, 2003
  2. Brendan Reynolds
    Replies:
    8
    Views:
    5,085
    Brendan Reynolds
    Aug 18, 2005
  3. Patrick.O.Ige
    Replies:
    3
    Views:
    5,443
    Patrick.O.Ige
    Oct 31, 2005
  4. csharper
    Replies:
    0
    Views:
    1,290
    csharper
    Aug 5, 2010
  5. SP
    Replies:
    0
    Views:
    744
Loading...

Share This Page