Re: The server committed a protocol violation

Tech-Archive recommends: Fix windows errors by optimizing your registry



Rather than relying on connection & authentication pooling to work
(because it doesn't for SSL, and only when requested for NTLM
[.UnsafeAuthenticatedConnectionSharing = true]), it's simplest to add
the authentication header manually. The example above demonstrates how
to do so for regular web requests. For soap clients, you'll need to add
an override to the GetWebRequest() method which adds the header there.
Still haven't looked at NTLM though.

protected override WebRequest GetWebRequest(Uri uri)
{
string user = "user";
string password = "password";

WebRequest request = base.GetWebRequest(uri);

request.Headers.Add(String.Format("Authorization: Basic {0}",
Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(
String.Format("{0}:{1}", user, password)))));

return request;
}

John S. wrote:
...

Basically, always ensure a standard web request has been made to the
device prior to making a SOAP call. When making the standard request,
be sure to manually add the Authorization header (only demonstrated for
Basic authentication below -- good luck with NTLM!). Be sure to set the
SoapServer's .PreAuthenticate property = true. The connection will be
re-used and the authentication will be sent properly.

The following work-around or some other accomplishing the same purpose
will be required to use .NET 2.0 HTTP/Soap helper classes to access
Windows CE-powered device web sites that require authentication (sorry
for the fomatting).

...

.



Relevant Pages

  • RE: HttpWebRequest over Https Via Proxy Fails using NTLM
    ... The proxy authentication header returns Basic, NTLM, and Negotiate. ... A network trace shows that the https request handshake is as follows: ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Each HTTP object being requested twice (401 then 200 responses)
    ... Authentication" and the web.config authentication setting is ... Authorized because the request was made anonymously. ... requests the same object a second time it uses kerberos; ... Kerberos and not NTLM, which is good since that's a requirement for ...
    (microsoft.public.inetserver.iis.security)
  • Re: HTTP - basic authentication example.
    ... or *never* knowing the realm..) ... This is called authentication and is implemented ... requests a web page it sends a request to the server. ... consists of headers with certain information about the request. ...
    (comp.lang.python)
  • Re: Each HTTP object being requested twice (401 then 200 responses)
    ... Authentication" and the web.config authentication setting is ... Authorized because the request was made anonymously. ... requests the same object a second time it uses kerberos; ... Kerberos tokens should not be regenerated for every request. ...
    (microsoft.public.inetserver.iis.security)
  • Re: IIS 6.0 Windows Authentication 401 Every Request
    ... After reading a lot of articles, I was finally able to get Kerberos and NTLM ... every request to a page, it'll throw a 401, and then the next request ... authentication, and have that work for the rest of the session. ...
    (microsoft.public.inetserver.iis.security)