Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / October 2003

Tip: Looking for answers? Try searching our database.

HTTP protocol violation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve Barta - 19 Sep 2003 22:42 GMT
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();
karursiva@yahoo.com - 03 Oct 2003 21:05 GMT
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();
--------------------------
karursiva@yahoo.com - 03 Oct 2003 21:05 GMT
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();
--------------------------

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.