How to authenticate HttpWebRequest?

M

Maras

Hi,

i have a protected part of application ("security" subdirectory is
protected by authentication mode="Forms").
i'd like to give a user a option to printfriendly version of content a page
in this directory.
in my printfriendly script i try to get a content of a page and then with
RegEx object to filter this content:
***
Dim URL as String = "http://myserver/security/test.aspx"
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(URL), _
HttpWebRequest)
' Sends the request and waits for a response.
Dim myHttpWebResponse As HttpWebResponse = _
CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
Dim receiveStream As Stream = myHttpWebResponse.GetResponseStream()
Dim encode As Encoding = System.Text.Encoding.GetEncoding("utf-8")
' Pipes the response stream to a higher level stream reader with the
' required encoding format.
Dim readStream As New StreamReader(receiveStream, encode)
Dim myHTML As String
myHTML = readStream.ReadToEnd
[...]
***
when i try to get the html code in not protected directory everything works
fine, but in security directory this myHttpWebRequest is probably not
authenticated and i get only my login page... i don't know why
myHttpWebRequest is not authenticated, i try to start this request in
security part, so after login, it should be authenticated.

have you any ideas to solve this problem?
thanks a lot.
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top