Click here to Skip to main content
15,897,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

i'm using HttpWebRequest to do a call to my SSRS Server to get a PDF exportation of my report.

Here's the code i'm using.

Dim reportURL As String = "http://server/ReportServer/Pages/ReportViewer.aspx?%2fRAM%2fBooking&rs:Command=Render&rs:Format=PDF"
Dim request As WebRequest

reportURL += "&idbooking=" + Session("idbooking").ToString

'main booking
request = System.Net.HttpWebRequest.Create(reportURL + "&idref=0")

request.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials


'Make a new attachment with the the stream from the response object
Attachment = New Attachment(request.GetResponse().GetResponseStream(), "Booking complet.pdf")

'Add this attachment to an email object
mail.Attachments.Add(Attachment)

This code works great in localmode.

When i'm trying that on my published web site, I get "The remote server returned an error: (403) Forbidden."

After read some articles, the problem seems to be because my website is using formauthentification.

With formauthentification it looks like I need to set authentification cookie to my HttpWebRequest object.

My problem is that I can't access to the CookieContainer property on my object.

request.cookieContainer return me that cookiecontainer is not a member of System.Net.WebRequest.

Why I'm not able to get access to this property?
What is my alternative?

Thanks a lot in advance.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900