ASP .net SQL Server Reporting Services 401 Error

R

RSH

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top