buran
New member
Dear .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,
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,