HTTP protocol violation

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default HTTP protocol violation

    I am writing a windows app that sends an HTTP request for
    xml data to a non-IIS server.
    No matter what I have tried I always get back the message
    "The underlying connection was closed: The server
    committed an HTTP protocol violation."

    They have a password challenge on the server. If I enter
    the url directly into IE it prompts me for the password
    which I enter. Then it returns the XML I am expecting.

    I can't seem to make this work in C#. What am I doing
    wrong?

    TIA!
    Steve

    Here is my code...
    HttpWebRequest webRequest = (HttpWebRequest)
    HttpWebRequest.Create(url);

    NetworkCredential myCred = new NetworkCredential(user,pw);

    CredentialCache myCache = new CredentialCache();
    myCache.Add(new Uri("target url here/"),"Basic",myCred);
    webRequest.Credentials = myCache;

    webRequest.KeepAlive = true;
    webRequest.PreAuthenticate = true; // this might be
    enough.
    webRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE
    6.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR
    1.1.4322)";
    webRequest.Accept = "image/gif, image/x-xbitmap,
    image/jpeg, image/pjpeg, application/x-shockwave-flash,
    */*"; webRequest.ProtocolVersion =
    HttpVersion.Version11;
    webRequest.Headers.Set("Accept-Language","en-us");
    webRequest.Headers.Set("Accept-Encoding","gzip,deflate");

    // this next call always throws and exception. (HTTP
    protocol violation)
    HttpWebResponse webResponse = (HttpWebResponse)
    webRequest.GetResponse();



    Steve Barta Guest

  2. Similar Questions and Discussions

    1. LazyHttp, or the HTTP protocol dissected...
      Howdy, I've been working on this solution for quite some time where we basically turn the HTTP protocol upside down and manages to have a "Message...
    2. HTTP Tunneling Protocol
      Anyone have insight into why co-browsed sessions might drop when using HTTP tunneling. Things are fine at first - connection successfully made...
    3. Form Problem after Publish with http protocol
      Any help would be greatly appreciated. I have published my web site using http protocol but the form still does not work. I set the form...
    4. Download a file using http protocol
      I've done something similar using the .net class WebClient Here is my function, it takes in two parameters: a URI to download from and the name...
    5. Websphere session persistence gets "protocol violation" using oracle jdbc driver
      Hi, We use oracle (8.1.7) as the session persistence database for our websphere 3.5.4 application server. After 15 min of running a stress test,...
  3. #2

    Default HTTP protocol violation

    I am writing a windows app that sends an HTTP request for
    xml data to a non-IIS server.
    No matter what I have tried I always get back the message
    "The underlying connection was closed: The server
    committed an HTTP protocol violation."

    They have a password challenge on the server. If I enter
    the url directly into IE it prompts me for the password
    which I enter. Then it returns the XML I am expecting.

    I can't seem to make this work in C#. What am I doing
    wrong?

    TIA!
    Steve

    Here is my code...
    HttpWebRequest webRequest = (HttpWebRequest)
    HttpWebRequest.Create(url);

    NetworkCredential myCred = new NetworkCredential(user,pw);

    CredentialCache myCache = new CredentialCache();
    myCache.Add(new Uri("target url here/"),"Basic",myCred);
    webRequest.Credentials = myCache;

    webRequest.KeepAlive = true;
    webRequest.PreAuthenticate = true; // this might be
    enough.
    webRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE
    6.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR
    1.1.4322)";
    webRequest.Accept = "image/gif, image/x-xbitmap,
    image/jpeg, image/pjpeg, application/x-shockwave-flash,
    */*"; webRequest.ProtocolVersion =
    HttpVersion.Version11;
    webRequest.Headers.Set("Accept-Language","en-us");
    webRequest.Headers.Set("Accept-Encoding","gzip,deflate");

    // this next call always throws and exception. (HTTP
    protocol violation)
    HttpWebResponse webResponse = (HttpWebResponse)
    webRequest.GetResponse();

    Steve Barta Guest

  4. #3

    Default Re: HTTP protocol violation


    Hi i have the sample problem .. if you found soloution please email me

    thanks
    siva

    ----------------My looks like this-----------
    NetworkCredential myCredentials = new NetworkCredential("admin",
    "1234");
    myCredentials.Domain = "addressbook";
    //i tried to put url or realm but nothing works

    WebRequest myWebRequest =
    WebRequest.Create("http://www.kitchentextile.com/siva/addressbook/addres
    s.xml");
    // here is the url location ...needs username and password to access
    this file.

    myWebRequest.PreAuthenticate=true;
    //i tried with and without this statement

    myWebRequest.Credentials = myCredentials;
    WebResponse myWebResponse = myWebRequest.GetResponse();
    //at this line , I get The remote server returned an error: (401)
    Unauthorized.

    myWebResponse.Close();
    --------------------------


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    karursiva@yahoo.com Guest

  5. #4

    Default Re: HTTP protocol violation

    Hi i have the sample problem .. if you found soloution please email me

    thanks
    siva

    ----------------My looks like this-----------
    NetworkCredential myCredentials = new NetworkCredential("admin",
    "1234");
    myCredentials.Domain = "addressbook";
    //i tried to put url or realm but nothing works

    WebRequest myWebRequest =
    WebRequest.Create("http://www.kitchentextile.com/siva/addressbook/addres
    s.xml");
    // here is the url location ...needs username and password to access
    this file.

    myWebRequest.PreAuthenticate=true;
    //i tried with and without this statement

    myWebRequest.Credentials = myCredentials;
    WebResponse myWebResponse = myWebRequest.GetResponse();
    //at this line , I get The remote server returned an error: (401)
    Unauthorized.

    myWebResponse.Close();
    --------------------------



    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    karursiva@yahoo.com Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139