locked
HTTPweb request works fine when Fiddler is on RRS feed

  • Question

  • User1455845355 posted

    Hi,

    I am trying to access a website using httpwebrequest.

    It is getting me response when Fiddler is turned on. But throws 401 unauthorized excpetion when Fiddler is not running.


    Appreciate your help in this regard.

    PFB my code:

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(sWebAddress);
                request.Credentials = new NetworkCredential("username", "pwd", "domain");

                CookieContainer cookieJar = new CookieContainer();
                request.CookieContainer = cookieJar;
                
                request.Accept = "*/*";           

                request.KeepAlive = true;
                
                // Get the response.
                WebResponse response = request.GetResponse();

                Stream dataStream = response.GetResponseStream();
                // Open the stream using a StreamReader for easy access.
                StreamReader reader = new StreamReader(dataStream);
                // Read the content.
                responseFromServer = reader.ReadToEnd();            
                // Clean up the streams.
                reader.Close();
                dataStream.Close();
                response.Close();

    Wednesday, December 2, 2009 5:07 AM

All replies

  • User-1363023537 posted

    Hi.

      HttpWebRequest has nothing to do with client side browser.

    Try it in another browser.


    Satalaj

    Wednesday, December 2, 2009 7:34 AM
  • User1455845355 posted

    Hi satalaj

    Am not trying it in browser. I am using HttpWebrequest in my app to access a website.

    It is working fine when I have fiddler on. Otherwise getting the exception "Unathourized".

    Wednesday, December 2, 2009 7:56 AM
  • User-1363023537 posted

    Hi.
     As per my knowledge Fiddler is client side plugin for browser.
    Can you tell me what exactly the fiddler is doing for you at server side ?

    Satalaj 

    Wednesday, December 2, 2009 8:35 AM
  • User1455845355 posted

    Hi,

    I found that Keep-Alive is not going in header when it is redirected.

    I have set "request.KeepAlive = true;" but still it is going in header.

    I am using .net 2.0 f/w.


    Regards,

    Rajiv.

    Thursday, December 3, 2009 9:16 AM
  • User-1363023537 posted

    Hi.
     Can you try to set

    request.ContentType = "application/x-www-form-urlencoded";   

    What is the use of fiddler in your scenario ?

     
    Satalaj

    Thursday, December 3, 2009 10:08 AM
  • User1455845355 posted

    It is not working.

    Thursday, December 10, 2009 3:36 AM