How to authenticate HttpWebRequest?

Discussion in 'ASP .Net Security' started by Maras, Dec 2, 2003.

  1. Maras

    Maras Guest

    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.
    --
    Cheers
    Maras
     
    Maras, Dec 2, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mae
    Replies:
    1
    Views:
    325
    Natty Gur
    Jul 7, 2003
  2. TruongLapVi

    Authenticate and session

    TruongLapVi, Feb 11, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    766
    =?Utf-8?B?QXZuZWVzaA==?=
    Feb 11, 2004
  3. =?Utf-8?B?TWFyaw==?=

    Authenticate the user

    =?Utf-8?B?TWFyaw==?=, Jul 14, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    333
    Curt_C [MVP]
    Jul 14, 2004
  4. Joeri KUMBRUCK
    Replies:
    1
    Views:
    4,567
    Ben Lovell
    Aug 30, 2004
  5. Sync Walantaji

    Authenticate users using AD and LDAP

    Sync Walantaji, Nov 15, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    11,664
    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=
    Nov 17, 2004
Loading...

Share This Page