By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,031 Members | 1,334 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,031 IT Pros & Developers. It's quick & easy.

webrequest and authentication problem

P: n/a
Dear ASP.NET Programmers,

Please consider the intranet site with the following forms authentication
page http://localhost/database/login.aspx. The usernames and passwords are
stored in the SQL Server database. After authenticating, the users are be
able to save the generated documents (HTML output of the generated document)
when they click on a button in http://localhost/database/medicalDocs/1.aspx.
I use the following code:

Dim wReq As WebRequest
Dim wResp As WebResponse
Dim srData As StreamReader
Dim fsDest As FileStream
Dim wrStream As StreamWriter
Dim buffer(1024) As Char
Dim intBytes As Integer
Dim strData As String

fsDest = New FileStream("d:\Downloads\doc.htm",
FileMode.OpenOrCreate, FileAccess.Write)
wrStream = New StreamWriter(fsDest)
wReq =
WebRequest.Create("http://localhost/database/medicalDocs/1.aspx")
wResp = wReq.GetResponse
srData = New StreamReader(wResp.GetResponseStream,
System.Text.Encoding.ASCII)
intBytes = srData.Read(buffer, 0, 1024)
Do While (intBytes > 0)
wrStream.Write(buffer, 0, intBytes)
intBytes = srData.Read(buffer, 0, 1024)
Loop
wrStream.Close()
srData.Close()
fsDest.Close()

but the saved document is the login page
(http://localhost/database/login.aspx) instead of the
http://localhost/database/medicalDocs/1.aspx. How can I supply the login
information with the WebRequest object or how can I work around it? Thanks
in advance,
Nov 20 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.