HTTPWebRequest, Proxy, Credentials?

Discussion in 'ASP .Net' started by moo, Jul 25, 2007.

  1. moo

    moo Guest

    Is there a simple way to get my logon credentials to make my web request
    work through our proxy server? I tried CredentialCache.DefaultCredentials,
    but I get nothing back. I can get it to work if I just create a new
    NetworkCredential object specifying user, password and domain. But, I would
    rather get that info automatically if possible, rather than presenting a
    winform for them to type it in.

    Lastly, why do both the request object and the request's proxy object have
    properties for credentials? Do I need to populate them both?

    Thanks,


    // WebRequest
    HttpWebRequest webRequest =
    (HttpWebRequest)WebRequest.Create(anyURL);
    webRequest.Timeout = 10000;
    webRequest.CookieContainer = cookieContainer;

    // Proxy Credentials?
    webRequest.Proxy = WebProxy.GetDefaultProxy();
    webRequest.Proxy.Credentials = new
    NetworkCredential("XXX","YYY","ZZZ");

    webRequest.Credentials = CredentialCache.DefaultCredentials;
    webRequest.Credentials = new
    NetworkCredential("XXX","YYY","ZZZ");
     
    moo, Jul 25, 2007
    #1
    1. Advertising

  2. moo

    bruce barker Guest

    the proxy server is a local server used to access the internet, and
    generally uses an internal account. the web server may have its own
    login requirements and may use the same login (or method). when using a
    proxy to access a local server the accounts may match.

    CredentialCache.DefaultCredentials is the current threads nt security
    token. if it doesn't work then its probably a local account without
    network access. for asp.net use a domain pool account, and be sure
    impersonation is off.

    -- bruce (sqlwork.com)

    moo wrote:
    > Is there a simple way to get my logon credentials to make my web request
    > work through our proxy server? I tried CredentialCache.DefaultCredentials,
    > but I get nothing back. I can get it to work if I just create a new
    > NetworkCredential object specifying user, password and domain. But, I would
    > rather get that info automatically if possible, rather than presenting a
    > winform for them to type it in.
    >
    > Lastly, why do both the request object and the request's proxy object have
    > properties for credentials? Do I need to populate them both?
    >
    > Thanks,
    >
    >
    > // WebRequest
    > HttpWebRequest webRequest =
    > (HttpWebRequest)WebRequest.Create(anyURL);
    > webRequest.Timeout = 10000;
    > webRequest.CookieContainer = cookieContainer;
    >
    > // Proxy Credentials?
    > webRequest.Proxy = WebProxy.GetDefaultProxy();
    > webRequest.Proxy.Credentials = new
    > NetworkCredential("XXX","YYY","ZZZ");
    >
    > webRequest.Credentials = CredentialCache.DefaultCredentials;
    > webRequest.Credentials = new
    > NetworkCredential("XXX","YYY","ZZZ");
    >
    >
    >
    >
    >
     
    bruce barker, Jul 25, 2007
    #2
    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. Jamie
    Replies:
    4
    Views:
    14,082
    Jamie
    Mar 1, 2004
  2. Scott Allen

    Re: httpwebrequest credentials

    Scott Allen, Sep 21, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,596
    =?Utf-8?B?Q296ZmVy?=
    Sep 27, 2004
  3. =?Utf-8?B?Q296ZmVy?=

    httpwebrequest credentials

    =?Utf-8?B?Q296ZmVy?=, Sep 21, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,343
    =?Utf-8?B?Q296ZmVy?=
    Sep 21, 2004
  4. Alex Hunsley
    Replies:
    1
    Views:
    6,405
    Alex Hunsley
    May 28, 2004
  5. msnews.microsoft.com
    Replies:
    0
    Views:
    913
    msnews.microsoft.com
    May 10, 2006
Loading...

Share This Page